I have an Elastic Search Query in JSON format (mentioned below) that I'm reading from a database and I will have to update this query in a Java spring program. How do I convert the JSON query object to a QueryBuilder object so that I can manipulate it before executing it to get the hits?
{
"query": {
"bool": {
"must_not": [
{
"match": {
"after.values": {
"query": "Beach Soccer",
"operator": "and"
}
}
},
{
"match": {
"after.values": {
"query": "Football",
"operator": "and"
}
}
}
],
"should": [
{
"match": {
"after.values": "Australian Open"
}
},
{
"match": {
"after.values": "Golf Austra"
}
},
{
"match": {
"after.values": "Australasia"
}
}
]
}
}
}
Same problem as How to construct QueryBuilder from JSON DSL when using Java API in ElasticSearch?
But the solution selected as answer there no longer works.
I have the exact same problem as @armstrongya in 2021 and doing QueryBuilders.wrapperQuery(jsonQueryString);
is not cutting it for me.
This is what I get :
{ "wrapper" : { "query" : "eyJib29sIjp7Im11c3Rfbm90IjpbeyJtYXRjaCI6eyJhZnRlci50aXRsZSI6eyJxdWVyeSI6IldpbWJlbGRvbiIsIm9wZXJhdG9yIjoiYW5kIn19fSx7Im1hdGNoIjp7ImZpZWxkLmRlc2NyaXB0aW9uIjp7InF1ZXJ5IjoiV2ltYmVsZG9uIiwib3BlcmF0b3IiOiJhbmQifX19LHsibWF0Y2giOnsiYWZ0ZXIudGl0bGUiOnsicXVlcnkiOiJXVEEiLCJvcGVyYXRvciI6ImFuZCJ9fX0seyJtYXRjaCI6eyJmaWVsZC5kZXNjcmlwdGlvbiI6eyJxdWVyeSI6IldUQSIsIm9wZXJhdG9yIjoiYW5kIn19fV19fQ==" }