# 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:** 1\
**Showing post:** 2

<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.

---

_[View the full topic](https://discuss.elastic.co/t/sqls-and-like-operation-in-elasticsearch-java-api/234097)._
