# Migration of elasticsearch java Client from 1.4.2 to 7.2 (problem in filteredQuery method)

**URL:** <https://discuss.elastic.co/t/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2-problem-in-filteredquery-method/189688>\
**Category:** Elasticsearch\
**Created:** [July 10, 2019, 8:17am UTC](https://discuss.elastic.co/t/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2-problem-in-filteredquery-method/189688 "2019-07-10T08:17:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![youssef\_elhayani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youssef_elhayani/32/49153_2.png) [@youssef\_elhayani](https://discuss.elastic.co/u/youssef_elhayani)\
**Post date:** [July 10, 2019, 8:17am UTC](https://discuss.elastic.co/t/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2-problem-in-filteredquery-method/189688/1 "2019-07-10T08:17:39Z")

</div>

Hi,

Currently i am running elasticsearch in 1.4.2 and I trying to make it run in 7.2 , the problem that i found is in The method **filteredQuery(MatchAllQueryBuilder, String, String)** and **filteredQuery(MatchAllQueryBuilder, QueryBuilder[])**, i didn't found any alternative methode knowing that they are deprecated, but for this implementation of filteredQuery : **filteredQuery(QueryBuilder,QueryBuilder)** i found that i should use boolquery() with filter clause.

Please, If there's any suggestion, do not hesitate.  
Thank You !

\*source:  
([https://static.javadoc.io/org.elasticsearch/elasticsearch/2.4.0/org/elasticsearch/index/query/QueryBuilder.html](https://static.javadoc.io/org.elasticsearch/elasticsearch/2.4.0/org/elasticsearch/index/query/QueryBuilder.html)) filterBuilder)

---

<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:** [July 10, 2019, 10:24am UTC](https://discuss.elastic.co/t/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2-problem-in-filteredquery-method/189688/2 "2019-07-10T10:24:14Z")

</div>

I think you should give this forum a chance before asking [in another place](https://stackoverflow.com/questions/56968584/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2).

> i found that i should use boolquery() with filter clause.

Yes you need to use `boolQuery()` instead.

---

<div class="post-metadata">

**Author:** ![youssef\_elhayani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youssef_elhayani/32/49153_2.png) [@youssef\_elhayani](https://discuss.elastic.co/u/youssef_elhayani)\
**Post date:** [July 10, 2019, 10:38am UTC](https://discuss.elastic.co/t/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2-problem-in-filteredquery-method/189688/3 "2019-07-10T10:38:02Z")

</div>

well, boolquery is for `filteredQuery(QueryBuilder,QueryBuilder)` , but for `filteredQuery(MatchAllQueryBuilder, String, String)` and `filteredQuery(MatchAllQueryBuilder, QueryBuilder[])` I don't think it match the boolquery() implementation, can you give an example of how i should use boolquery for these two case of filteredQuery ?

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:** [July 10, 2019, 10:54am UTC](https://discuss.elastic.co/t/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2-problem-in-filteredquery-method/189688/4 "2019-07-10T10:54:46Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

Then based on this Kibana script we can find what would be the Java code.

---

<div class="post-metadata">

**Author:** ![youssef\_elhayani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youssef_elhayani/32/49153_2.png) [@youssef\_elhayani](https://discuss.elastic.co/u/youssef_elhayani)\
**Post date:** [July 10, 2019, 11:11am UTC](https://discuss.elastic.co/t/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2-problem-in-filteredquery-method/189688/5 "2019-07-10T11:11:45Z")

</div>

```
private QueryBuilder queryBuilder() {
	QueryBuilder fb = queryCatBuilder();
	BoolQueryBuilder builder = QueryBuilders.boolQuery();
	if(request.getContent() == null || "".equals(request.getContent())){
		if(fb == null)
			return QueryBuilders.matchAllQuery();
		builder.filter(QueryBuilders.matchAllQuery()).filter(fb);

		return builder;
	}
	if(fb == null)
		return QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), FIELD_ALL, 
				request.getContent());
	return QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(),
			fb,QueryBuilders.termQuery(FIELD_ALL, 
					request.getContent().toLowerCase()));
}

```

see the returns statement.

---

<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:** [July 10, 2019, 12:32pm UTC](https://discuss.elastic.co/t/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2-problem-in-filteredquery-method/189688/7 "2019-07-10T12:32:50Z")

</div>

Please provide a Kibana script that we can run in Kibana dev console.

---

<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:** [August 7, 2019, 12:33pm UTC](https://discuss.elastic.co/t/migration-of-elasticsearch-java-client-from-1-4-2-to-7-2-problem-in-filteredquery-method/189688/8 "2019-08-07T12:33:00Z")

</div>

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