ropensci / elastic

R client for the Elasticsearch HTTP API
https://docs.ropensci.org/elastic
Other
244 stars 58 forks source link

Get curl request from Search? #171

Closed komalsrathi closed 7 years ago

komalsrathi commented 7 years ago

When using Search, is it possible to get the curl request that is hitting the elastic search server?

My query is something like this:

out <- Search(index = index, 
       type = type, 
       q = query, 
       body = body, 
       raw = TRUE)

I want to know the corresponding request that is getting data from the server.

sckott commented 7 years ago

not a full curl request, but can see verbose output with config=httr::verbose(), like Search(config=httr::verbose())

komalsrathi commented 7 years ago

oh okay. The reason I wanted to see the curl request was because in the database schema I am trying to query, the nested fields are not mapped as "nested" which is required for querying a nested query - I guess? That's why I am not directly able to use curl to filter on a particular nested field. But when I use your package, I am able to filter using a . e.g. gene_info.symbol:(PKD1 OR AAAS OR A2M). So I wanted to check what request is actually hitting the server.

sckott commented 7 years ago

okay, sounds good, can i close this (is your problem sorted)?

komalsrathi commented 7 years ago

Yes - my problem is not solved but I guess there is no way to get the request. I will close it.

sckott commented 7 years ago

it's a bit beyond scope here to output curl requests - but i think we can easily get it sorted out.

If you're doing out <- Search(index = index, type = type, q = query, body = body)

Then curl request should be something like

curl -H 'Content-Type: application/json' 'http://localhost:9200/plos/article/_search' -d '
  { "query":{
     "bool" : {
       "should" : {
          "match" : {
            "title" : "cells"
        }
     }
  }
}}'