0

elasticsearch wrapper query not works with base64 encoded string

ES version : 5.2.3

To encode i have used base64:

char[] data = Base64Coder.encode(text.getBytes());

return data.ToString();

Note: text is the underline json query.

query:

curl -d XPOST 'http://localhost:9200/entitymaster_qa_t4/_search' -d '{
  "query" : {
    "wrapper" : {
      "query" : "W0NAMTZiN2MzYw=="
    }
  }
}'

Response:

{"error":{"root_cause":[{"type":"parse_exception","reason":"Failed to derive xcontent"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"entitymaster_qa_t4","node":"8WVaVr9ATmaqOPDHGpNyHw","reason":{"type":"parse_exception","reason":"Failed to derive xcontent"}}]},"status":400}

1 Answers1

0

The wrapper query appeared in ES 6.0 according to the docs, so if you want to use it you need to update your version. Also, the base64 string must decode into a valid query, not just a piece of data.

Stock Overflaw
  • 3,203
  • 1
  • 13
  • 14
  • thank you. is there any elastic Java API that accept JSON query string to execute against the index?? – Rajadurai wilbert Oct 08 '18 at 06:53
  • I don't know, but [this post](https://stackoverflow.com/questions/25859921/how-to-construct-querybuilder-from-json-dsl-when-using-java-api-in-elasticsearch) seems to hold your answer. – Stock Overflaw Oct 10 '18 at 07:15