3

ES HighLevelRestClient

how to use ES HighLevelRestClient search by a custom JSON.

I have a query JSON like:

{
  "from": 0,
  "size": 20,
  "query": {
    "bool": {
    "must": [
        {
          "match": {
            "name": "test"
          }
        }
      ]
    }
  }
}

this JSON generated by mustache template mustache java . cause I don't want to use QueryBuilder.

so I want to know how to search by custom JSON use HightLevelClient?

P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66
Jarvis
  • 371
  • 1
  • 10
  • 22
  • 1
    Why not using the [search template API](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-search-template.html) directly? – Val Jun 03 '19 at 04:37
  • my version is: `6.3.0` cause ES-version is 6.3.0, not support for that /(ㄒoㄒ)/~~, or any problem if I use Client-Version `7.0` with ES-Version `6.3.0` ? – Jarvis Jun 03 '19 at 06:26
  • Even if that does not answer your question, your `bool` field should be wrapped in a `query` object. – Pierre-Nicolas Mougel Jun 03 '19 at 08:44
  • Have you looked at the answers of [this question](https://stackoverflow.com/q/48399046/3262646) ? It seems very similar to what you want to do. – Pierre-Nicolas Mougel Jun 03 '19 at 08:52

0 Answers0