title: Construct QueryBuilder from JSON DSL when using Java API in ElasticSearch?
body: <p>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?</p>
  <pre><code>{
    &quot;query&quot;: {
      &quot;bool&quot;: {
        &quot;must_not&quot;: [
          {
            &quot;match&quot;: {
              &quot;after.values&quot;: {
                &quot;query&quot;: &quot;Beach Soccer&quot;,
                &quot;operator&quot;: &quot;and&quot;
              }
            }
          },
          {
            &quot;match&quot;: {
              &quot;after.values&quot;: {
                &quot;query&quot;: &quot;Football&quot;,
                &quot;operator&quot;: &quot;and&quot;
              }
            }
          }
        ],
        &quot;should&quot;: [
          {
            &quot;match&quot;: {
              &quot;after.values&quot;: &quot;Australian Open&quot;
            }
          },
          {
            &quot;match&quot;: {
              &quot;after.values&quot;: &quot;Golf Austra&quot;
            }
          },
          {
            &quot;match&quot;: {
              &quot;after.values&quot;: &quot;Australasia&quot;
            }
          }
        ]
      }
    }
  }
  </code></pre>
  <p>Same problem as <a href="https://stackoverflow.com/questions/25859921/how-to-construct-querybuilder-from-json-dsl-when-using-java-api-in-elasticsearch/67027998#67027998">How to construct QueryBuilder from JSON DSL when using Java API in ElasticSearch?</a></p>
  <p>But the solution selected as answer there no longer works.
  I have the exact same problem as @armstrongya in 2021 and doing <code>QueryBuilders.wrapperQuery(jsonQueryString); </code>
  is not cutting it for me.</p>
  <p>This is what I get :</p>
  <p>{ &quot;wrapper&quot; : { &quot;query&quot; : &quot;eyJib29sIjp7Im11c3Rfbm90IjpbeyJtYXRjaCI6eyJhZnRlci50aXRsZSI6eyJxdWVyeSI6IldpbWJlbGRvbiIsIm9wZXJhdG9yIjoiYW5kIn19fSx7Im1hdGNoIjp7ImZpZWxkLmRlc2NyaXB0aW9uIjp7InF1ZXJ5IjoiV2ltYmVsZG9uIiwib3BlcmF0b3IiOiJhbmQifX19LHsibWF0Y2giOnsiYWZ0ZXIudGl0bGUiOnsicXVlcnkiOiJXVEEiLCJvcGVyYXRvciI6ImFuZCJ9fX0seyJtYXRjaCI6eyJmaWVsZC5kZXNjcmlwdGlvbiI6eyJxdWVyeSI6IldUQSIsIm9wZXJhdG9yIjoiYW5kIn19fV19fQ==&quot; }</p>