# Is elasticsearch be able to index n-gram phrase？

**URL:** <https://discuss.elastic.co/t/is-elasticsearch-be-able-to-index-n-gram-phrase/13517>\
**Category:** Elasticsearch\
**Created:** [September 9, 2013, 1:39pm UTC](https://discuss.elastic.co/t/is-elasticsearch-be-able-to-index-n-gram-phrase/13517 "2013-09-09T13:39:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lord\_Artois](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@Lord\_Artois](https://discuss.elastic.co/u/Lord_Artois)\
**Post date:** [September 9, 2013, 1:39pm UTC](https://discuss.elastic.co/t/is-elasticsearch-be-able-to-index-n-gram-phrase/13517/1 "2013-09-09T13:39:46Z")

</div>

Hi, I am wondering if we can use elastic search to do multi-level indexing, for  
example:  
if I want to index text like: "Lookup by an arbitraty identifier in MSMQ"  
Obviously, with the standard analyzer,  
it could be tokenized like "Lookup", "by", "an", etc  
But what if in addition to index each token (word), I also want to index  
n-gram phrase,  
like "Lookup by an", "by an arbitraty", "an arbitraty identifier", etc  
I saw elasticsearch has some n-gram options, but looks like the n-gram is  
made up by n char, "Loo", "ook", "oku", "kup", etc  
which are not n-gram phrases made up by n tokens(word)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [September 9, 2013, 1:47pm UTC](https://discuss.elastic.co/t/is-elasticsearch-be-able-to-index-n-gram-phrase/13517/2 "2013-09-09T13:47:24Z")

</div>

Hi,

You should have a look at the shingle filter[1], which seems to do what you  
are looking for.

[1]

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

On Mon, Sep 9, 2013 at 3:39 PM, Lord Artois [duketristan@gmail.com](mailto:duketristan@gmail.com) wrote:

> Hi, I am wondering if we can use Elasticsearch to do multi-level  
> indexing, for example:  
> if I want to index text like: "Lookup by an arbitraty identifier in MSMQ"  
> Obviously, with the standard analyzer,  
> it could be tokenized like "Lookup", "by", "an", etc  
> But what if in addition to index each token (word), I also want to index  
> n-gram phrase,  
> like "Lookup by an", "by an arbitraty", "an arbitraty identifier", etc  
> I saw elasticsearch has some n-gram options, but looks like the n-gram is  
> made up by n char, "Loo", "ook", "oku", "kup", etc  
> which are not n-gram phrases made up by n tokens(word)
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Adrien Grand

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Lord\_Artois](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@Lord\_Artois](https://discuss.elastic.co/u/Lord_Artois)\
**Post date:** [September 9, 2013, 3:03pm UTC](https://discuss.elastic.co/t/is-elasticsearch-be-able-to-index-n-gram-phrase/13517/3 "2013-09-09T15:03:10Z")

</div>

Great, it looks like exacly what I am looking for.  
Thank you Adrien

On Monday, September 9, 2013 9:47:24 PM UTC+8, Adrien Grand wrote:

> Hi,
> 
> You should have a look at the shingle filter[1], which seems to do what  
> you are looking for.
> 
> [1]  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/shingle-tokenfilter/)
> 
> On Mon, Sep 9, 2013 at 3:39 PM, Lord Artois \<[duket...@gmail.com](mailto:duket...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi, I am wondering if we can use Elasticsearch to do multi-level  
> > indexing, for example:  
> > if I want to index text like: "Lookup by an arbitraty identifier in MSMQ"  
> > Obviously, with the standard analyzer,  
> > it could be tokenized like "Lookup", "by", "an", etc  
> > But what if in addition to index each token (word), I also want to index  
> > n-gram phrase,  
> > like "Lookup by an", "by an arbitraty", "an arbitraty identifier", etc  
> > I saw elasticsearch has some n-gram options, but looks like the n-gram  
> > is made up by n char, "Loo", "ook", "oku", "kup", etc  
> > which are not n-gram phrases made up by n tokens(word)
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Adrien Grand

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:17am UTC](https://discuss.elastic.co/t/is-elasticsearch-be-able-to-index-n-gram-phrase/13517/4 "2017-07-06T02:17:28Z")

</div>


