Executing JSON query directly using Java API ignore the query algother

In my application, we build the search query in JSON format.e.g

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "officeCode.keyword": {
              "value": "410"
            }
          }
        },
        {
          "terms": {
            "status.keyword": [
              "CLOSED",
              "CREDIT"
            ]
          }
        }
        ]
    }
  }
}

We use Elasticsearch Java 8.X API to execute the query using "co.elastic.clients.elasticsearch.ElasticsearchClient;"

String encodedJson = Base64.getEncoder().encodeToString(jsonQuery.getBytes());
     SearchResponse<Map> searchResponse = elasticsearchClient.search(s -> s
                    .index(indexName)
                    .query(b -> b.queryString(b1 -> b1.query(encodedJson ))), Map.class);

I noticed that it completely ignores the query and returns the default max size. It does not throw an error, either. I also try to use the native JSON without encoding, but then it throws a "sharding error".

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