# Sql's AND like operation in elasticsearch java-api

**URL:** <https://discuss.elastic.co/t/sqls-and-like-operation-in-elasticsearch-java-api/234097>\
**Category:** Elasticsearch\
**Created:** [May 25, 2020, 7:42am UTC](https://discuss.elastic.co/t/sqls-and-like-operation-in-elasticsearch-java-api/234097 "2020-05-25T07:42:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohit.singh3](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@rohit.singh3](https://discuss.elastic.co/u/rohit.singh3)\
**Post date:** [May 25, 2020, 7:42am UTC](https://discuss.elastic.co/t/sqls-and-like-operation-in-elasticsearch-java-api/234097/1 "2020-05-25T07:42:19Z")

</div>

can anyone suggest how to write AND like oparation in java

---

<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:** [May 25, 2020, 8:43am UTC](https://discuss.elastic.co/t/sqls-and-like-operation-in-elasticsearch-java-api/234097/2 "2020-05-25T08:43:32Z")

</div>

Here is my suggestion.

You first try to find the right query for your use case using the query DSL.  
Here you probably want to use a [`bool` query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html) with `filter` or `must` clauses.

If you can't write it by yourself, you can try the [SQL Translate API](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate.html).

Once you have the right query working, you can transform it to Java Code using the [search API](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-search.html).

Have a look at [QueryBuilders](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-search.html#java-rest-high-search-request-building-queries) as well.

If you need help, please 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.

A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case.

---

<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:** [June 22, 2020, 8:43am UTC](https://discuss.elastic.co/t/sqls-and-like-operation-in-elasticsearch-java-api/234097/3 "2020-06-22T08:43:39Z")

</div>

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