ropensci / elastic

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

Question: how to translate bool into list form in R elastic #179

Closed nancyzhu24 closed 6 years ago

nancyzhu24 commented 7 years ago

I am wondering how I can translate a bool query in the body into list form? For example for the following code:

GET shakespeare/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {"play_name": "henry"}
        },
        {"match": {"speaker": "King"}
          },
          {
            "match":{
            "text_entry":"no"
          }
        }
      ]
    }
  }
}

Also once in the list form, can I use Search as part of a function in R?

sckott commented 7 years ago

@nancyzhu24 can you share your sessionInfo() plz

sckott commented 7 years ago

Try

mylist <- dput(jsonlite::fromJSON(
'{
  "query": {
    "bool": {
      "must": [
        {
          "match": {"play_name": "henry"}
        },
        {"match": {"speaker": "King"}
        },
        {
          "match":{
            "text_entry":"no"
          }
        }
        ]
    }
  }
}', FALSE))
mylist
sckott commented 6 years ago

closing due to no response