# Could not find commonTermsQuery api for elasticsearch5.1.1

**URL:** <https://discuss.elastic.co/t/could-not-find-commontermsquery-api-for-elasticsearch5-1-1/82245>\
**Category:** Elasticsearch\
**Created:** [April 13, 2017, 5:27am UTC](https://discuss.elastic.co/t/could-not-find-commontermsquery-api-for-elasticsearch5-1-1/82245 "2017-04-13T05:27:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellosearch](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@hellosearch](https://discuss.elastic.co/u/hellosearch)\
**Post date:** [April 13, 2017, 5:27am UTC](https://discuss.elastic.co/t/could-not-find-commontermsquery-api-for-elasticsearch5-1-1/82245/1 "2017-04-13T05:27:50Z")

</div>

it could not find commonTermsQuery api for elasticsearch5.1.1, detail below：  
//set cluster name  
Settings settings = Settings.builder().put("[cluster.name](http://cluster.name)", "es5-cluster").build();  
TransportClient client = new PreBuiltTransportClient(settings)  
.addTransportAddress(  
new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));// 127.0.0.1

//it could not find below api  
QueryBuilder qb = commonTermsQuery("name","kimchy");

already added dependcy in pom.xml:

```
<dependency>
	<groupId>org.elasticsearch</groupId>
	<artifactId>elasticsearch</artifactId>
	<version>5.1.1</version>
</dependency>	

<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/transport -->
<dependency>
	<groupId>org.elasticsearch.client</groupId>
	<artifactId>transport</artifactId>
	<version>5.1.1</version>
</dependency>

```

please help, thanks~~~

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [April 13, 2017, 10:47am UTC](https://discuss.elastic.co/t/could-not-find-commontermsquery-api-for-elasticsearch5-1-1/82245/2 "2017-04-13T10:47:47Z")

</div>

Hi,

`commonTermsQuery()` is a static helper method in `org.elasticsearch.index.query.QueryBuilders`. So either import QueryBuilders and then do `QueryBuilders.commonTermsQuery("name","kimchy");` or do a static import and you can ommit the class. Hope that helps.

---

<div class="post-metadata">

**Author:** ![hellosearch](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@hellosearch](https://discuss.elastic.co/u/hellosearch)\
**Post date:** [April 14, 2017, 2:16am UTC](https://discuss.elastic.co/t/could-not-find-commontermsquery-api-for-elasticsearch5-1-1/82245/3 "2017-04-14T02:16:56Z")

</div>

hi, thanks your reply, it may fix my question^\_^.

---

<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:** [May 12, 2017, 2:19am UTC](https://discuss.elastic.co/t/could-not-find-commontermsquery-api-for-elasticsearch5-1-1/82245/4 "2017-05-12T02:19:40Z")

</div>

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