# Query for contains

**URL:** <https://discuss.elastic.co/t/query-for-contains/5090>\
**Category:** Elasticsearch\
**Created:** [August 8, 2011, 9:04pm UTC](https://discuss.elastic.co/t/query-for-contains/5090 "2011-08-08T21:04:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartavya](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kartavya](https://discuss.elastic.co/u/Kartavya)\
**Post date:** [August 8, 2011, 9:04pm UTC](https://discuss.elastic.co/t/query-for-contains/5090/1 "2011-08-08T21:04:09Z")

</div>

Hi All,  
I want to write a percolate query that match the document containing the  
term as sub-string.

like a contains query.  
Example:  
a document in index like filed1:"dtfinanace"

must be returned in result if I search for "fields:"finance".

Any help will be highly appreciated.

Thnaks,  
Pulkit Agrawal

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [August 8, 2011, 9:35pm UTC](https://discuss.elastic.co/t/query-for-contains/5090/2 "2011-08-08T21:35:20Z")

</div>

While you could do wildcard queries, I don't believe they are very  
efficient. I'd recommend using an n-gram analyzer:  
[http://search.lucidimagination.com/search/document/CDRG\_ch05\_5.5.5](http://search.lucidimagination.com/search/document/CDRG_ch05_5.5.5)

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

Best Regards,  
Paul

On Aug 8, 3:04 pm, Pulkit Agrawal [pulkitdot...@gmail.com](mailto:pulkitdot...@gmail.com) wrote:

> Hi All,  
> I want to write a percolate query that match the document containing the  
> term as sub-string.
> 
> like a contains query.  
> Example:  
> a document in index like filed1:"dtfinanace"
> 
> must be returned in result if I search for "fields:"finance".
> 
> Any help will be highly appreciated.
> 
> Thnaks,  
> Pulkit Agrawal

---

<div class="post-metadata">

**Author:** ![Kartavya](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kartavya](https://discuss.elastic.co/u/Kartavya)\
**Post date:** [August 9, 2011, 6:02pm UTC](https://discuss.elastic.co/t/query-for-contains/5090/3 "2011-08-09T18:02:32Z")

</div>

Thanks Paul,

I will try that.  
Does it work in percolate as well?

Regards,  
Pulkit Agrawal

On Tue, Aug 9, 2011 at 3:05 AM, ppearcy [ppearcy@gmail.com](mailto:ppearcy@gmail.com) wrote:

> While you could do wildcard queries, I don't believe they are very  
> efficient. I'd recommend using an n-gram analyzer:  
> [http://search.lucidimagination.com/search/document/CDRG\_ch05\_5.5.5](http://search.lucidimagination.com/search/document/CDRG_ch05_5.5.5)
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/ngram-tokenizer.html)
> 
> Best Regards,  
> Paul
> 
> On Aug 8, 3:04 pm, Pulkit Agrawal [pulkitdot...@gmail.com](mailto:pulkitdot...@gmail.com) wrote:
> 
> > Hi All,  
> > I want to write a percolate query that match the document containing the  
> > term as sub-string.
> > 
> > like a contains query.  
> > Example:  
> > a document in index like filed1:"dtfinanace"
> > 
> > must be returned in result if I search for "fields:"finance".
> > 
> > Any help will be highly appreciated.
> > 
> > Thnaks,  
> > Pulkit Agrawal

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [August 10, 2011, 12:04am UTC](https://discuss.elastic.co/t/query-for-contains/5090/4 "2011-08-10T00:04:40Z")

</div>

Yeah, you should be able to save and percolate any query that you can  
run through the search APIs.

Regards,  
Paul

On Aug 9, 12:02 pm, Pulkit Agrawal [pulkitdot...@gmail.com](mailto:pulkitdot...@gmail.com) wrote:

> Thanks Paul,
> 
> I will try that.  
> Does it work in percolate as well?
> 
> Regards,  
> Pulkit Agrawal
> 
> On Tue, Aug 9, 2011 at 3:05 AM, ppearcy [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> 
> > While you could do wildcard queries, I don't believe they are very  
> > efficient. I'd recommend using an n-gram analyzer:  
> > [http://search.lucidimagination.com/search/document/CDRG\_ch05\_5.5.5](http://search.lucidimagination.com/search/document/CDRG_ch05_5.5.5)
> 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/n)...
> 
> > Best Regards,  
> > Paul
> 
> > On Aug 8, 3:04 pm, Pulkit Agrawal [pulkitdot...@gmail.com](mailto:pulkitdot...@gmail.com) wrote:
> > 
> > > Hi All,  
> > > I want to write a percolate query that match the document containing the  
> > > term as sub-string.
> 
> > > like a contains query.  
> > > Example:  
> > > a document in index like filed1:"dtfinanace"
> 
> > > must be returned in result if I search for "fields:"finance".
> 
> > > Any help will be highly appreciated.
> 
> > > Thnaks,  
> > > Pulkit Agrawal

---

<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, 3:57am UTC](https://discuss.elastic.co/t/query-for-contains/5090/5 "2017-07-06T03:57:40Z")

</div>


