# LIKE Query

**URL:** <https://discuss.elastic.co/t/like-query/23488>\
**Category:** Elasticsearch\
**Created:** [April 30, 2015, 12:10pm UTC](https://discuss.elastic.co/t/like-query/23488 "2015-04-30T12:10:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavanbnv](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@pavanbnv](https://discuss.elastic.co/u/pavanbnv)\
**Post date:** [April 30, 2015, 12:10pm UTC](https://discuss.elastic.co/t/like-query/23488/1 "2015-04-30T12:10:18Z")

</div>

Hi All,

Is there any way to find documents by querying fields for matching terms similar to database LIKE  
I have gone thru some of the queries which are dated 2012, 2011. None of them has straightforward answer. Not sure of we have the feature in current version 1.4.5

I want some thing like ...

Actual data : Field1 : Something similar to this

My queries : "omething simi"  
,"ilar to thi" should be able to retrieve the document.

Can anyone let me know how to achieve this??

---

<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:** [April 30, 2015, 1:25pm UTC](https://discuss.elastic.co/t/like-query/23488/2 "2015-04-30T13:25:16Z")

</div>

You need first to understand that a search engine is not a SQL like system.  
It’s based on a inverted index so what you query is not your source data but the index you have created.

The way you build your index is extremely important then.  
You could imagine using wildcard queries but first it would inefficient and it would require that instead of indexing tokens you index full sentences.

I suggest that you first read this chapter (go through all sections): [Mapping and Analysis | Elasticsearch: The Definitive Guide [2.x] | Elastic](http://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-analysis.html) [http://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-analysis.html](http://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-analysis.html)

Answering to your question, using ngrams would probably help here.

Hope this helps

--  
David Pilato - Developer | Evangelist

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co/)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 30 avr. 2015 à 14:10, pavanbnv [pavan.bnv@gmail.com](mailto:pavan.bnv@gmail.com) a écrit :
> 
> Hi All,
> 
> Is there any way to find documents by querying fields for matching terms  
> similar to database LIKE  
> I have gone thru some of the queries which are dated 2012, 2011. None of  
> them has straightforward answer. Not sure of we have the feature in current  
> version 1.4.5
> 
> I want some thing like ...
> 
> Actual data : Field1 : Something similar to this
> 
> My queries : "omething simi"  
> ,"ilar to thi" should be able to retrieve the document.
> 
> Can anyone let me know how to achieve this??
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/LIKE-Query-tp4074378.html](http://elasticsearch-users.115913.n3.nabble.com/LIKE-Query-tp4074378.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1430395818238-4074378.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1430395818238-4074378.post%40n3.nabble.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3199B348-31DB-47A8-9E67-64994E8AD364%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/3199B348-31DB-47A8-9E67-64994E8AD364%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:16am UTC](https://discuss.elastic.co/t/like-query/23488/3 "2017-07-06T00:16:43Z")

</div>


