# Replacement of QueryBuilder(ES 5.6) in ES 8.5

**URL:** <https://discuss.elastic.co/t/replacement-of-querybuilder-es-5-6-in-es-8-5/323856>\
**Category:** Elasticsearch\
**Created:** [January 24, 2023, 3:37pm UTC](https://discuss.elastic.co/t/replacement-of-querybuilder-es-5-6-in-es-8-5/323856 "2023-01-24T15:37:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harsh0145](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harsh0145/32/116118_2.png) [@Harsh0145](https://discuss.elastic.co/u/Harsh0145)\
**Post date:** [January 24, 2023, 3:37pm UTC](https://discuss.elastic.co/t/replacement-of-querybuilder-es-5-6-in-es-8-5/323856/1 "2023-01-24T15:37:06Z")

</div>

Hi,  
We have been using the ES 5.6 cluster, but are now migrating to a new ES 8.5 cluster. The Data migration, and indexing queries are all sorted. However, earlier we used to use QueryBuilder in ES 5.6 java app and there is no example of this in the new Java Client Library of ES. Would it be possible if we could get an example, of how we can dynamically create queries, by adding boolean statements.  
Thank You

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 24, 2023, 4:01pm UTC](https://discuss.elastic.co/t/replacement-of-querybuilder-es-5-6-in-es-8-5/323856/2 "2023-01-24T16:01:30Z")

</div>

I think you'll find a good start here:

> **[Searching for documents | Elasticsearch Java API Client \[8.6\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/searching.html)**

---

<div class="post-metadata">

**Author:** ![Harsh0145](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harsh0145/32/116118_2.png) [@Harsh0145](https://discuss.elastic.co/u/Harsh0145)\
**Post date:** [January 25, 2023, 4:39am UTC](https://discuss.elastic.co/t/replacement-of-querybuilder-es-5-6-in-es-8-5/323856/3 "2023-01-25T04:39:23Z")

</div>

Hi @dadoonet , thanks for a quick response. However, I have gone through this page before and this provides a functional approach to building queries. We cannot add queries to it, condition by condition. We'll have to make the query at once. Is there a way to do this using the Builder approach, if any?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 25, 2023, 9:49am UTC](https://discuss.elastic.co/t/replacement-of-querybuilder-es-5-6-in-es-8-5/323856/4 "2023-01-25T09:49:44Z")

</div>

I think that you can use something similar as shown in [Searching for documents | Elasticsearch Java API Client [8.6] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/searching.html#_nested_search_queries)

```auto
Query byName = MatchQuery.of(m -> m 
    .field("name")
    .query(searchText)
)._toQuery();

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 22, 2023, 9:50am UTC](https://discuss.elastic.co/t/replacement-of-querybuilder-es-5-6-in-es-8-5/323856/5 "2023-02-22T09:50:01Z")

</div>

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