I'm trying to use WrapperQuery to run a raw query like this
String queryStr = "{\n" +
" \"query\": {\n" +
" \"bool\": {\n" +
" \"must\": [\n" +
" {\n" +
" \"match\": {\n" +
" \"type\": \"MyType\"\n" +
" }\n" +
" }\n" +
" ]\n" +
" }\n" +
" }\n" +
"}";
String encodedString = Base64.getEncoder().encodeToString(queryStr.getBytes());
Query wq = QueryBuilders.wrapper(w->w.query(encodedString));
But get the below error when executing the search.
ErrorResponse: {"error":{"col":12,"line":2,"type":"parsing_exception","reason":"unknown query [query]","status":400}
However, if I remove the "query" element from the raw query JSON, I can execute the wrapper query.
E.g.
String queryStr = "{
"bool": {
"must": [
{
"match": {
"type": "MyType"
}
}
]
}
}"
gives me matching results.
Can you please provide an example to run a more complicated raw query having elements outside the "query" element like below:
String queryStr = "{
"query": {
"bool": {
"must": [
{
"match": {
"type": "MyChange"
}
}
]
},
"size": 30,
"from": 0,
"sort": [
{
"change": {
"order": "desc"
}
}
]
}
}"
Many thanks.