How to use multiple fields in exists query in Java API in Elasticsearch 2.4.4

From the REST API of the elasticsearch(version 2.4.4), we can use multiple fields in exists query as:

{
  "query": {
    "exists": {
      "field": [
        "field1",
        "field2",
        "field3"
      ]
    }
  }
}

But I couldn't find the equivalent Java API for the same. The java class ExistsQueryBuilder takes only one field as the constructor. So, isn't there really any Java API for it? So, the only way to do it from Java API is using bool-should of exists query for each field?

I'm curious to know where did you see that you can give an array as input to the exists query?
As far as I know, only a single field is supported.

And if you try your query, you'd get the following error:

[exists] unknown token [START_ARRAY] after [field]

The above query is working for me. Elasticsearch version 2.4.4.

Oh, ok, I tested on 5.6 and 6.4, makes sense :slight_smile:

Sorry, I forget to mention the version. Will edit it.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.