# NGram question

**URL:** <https://discuss.elastic.co/t/ngram-question/4733>\
**Category:** Elasticsearch\
**Created:** [June 29, 2011, 9:35am UTC](https://discuss.elastic.co/t/ngram-question/4733 "2011-06-29T09:35:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre\_Heimburger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexandre_heimburger/32/2941_2.png) [@Alexandre\_Heimburger](https://discuss.elastic.co/u/Alexandre_Heimburger)\
**Post date:** [June 29, 2011, 9:35am UTC](https://discuss.elastic.co/t/ngram-question/4733/1 "2011-06-29T09:35:10Z")

</div>

Hello there,

I index a document containing the sentence "please search me".

I would like to retrieve this document by searching :

- please

- PlEasE

- pleas

- ase sear

- earch me

etc etc....

Some people told me that NGram was great and faster than prefixed  
queries.

But it does not work for me.

Could you please give me the analyzer configuration and the mapping  
for this use case ?

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Paul\_Loy](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@Paul\_Loy](https://discuss.elastic.co/u/Paul_Loy)\
**Post date:** [June 29, 2011, 9:38am UTC](https://discuss.elastic.co/t/ngram-question/4733/2 "2011-06-29T09:38:20Z")

</div>

Please gist ([https://gist.github.com/](https://gist.github.com/)) your example and we'll try to find  
out what you've missed.

Thanks,

Paul.

On Wed, Jun 29, 2011 at 10:35 AM, alheim [alexheimburger@gmail.com](mailto:alexheimburger@gmail.com) wrote:

> Hello there,
> 
> I index a document containing the sentence "please search me".
> 
> I would like to retrieve this document by searching :
> 
> - please
> 
> - PlEasE
> 
> - pleas
> 
> - ase sear
> 
> - earch me
> 
> etc etc....
> 
> Some people told me that NGram was great and faster than prefixed  
> queries.
> 
> But it does not work for me.
> 
> Could you please give me the analyzer configuration and the mapping  
> for this use case ?
> 
> Thanks a lot.

## --

Paul Loy  
[paul@keteracel.com](mailto:paul@keteracel.com)  
[http://uk.linkedin.com/in/paulloy](http://uk.linkedin.com/in/paulloy)

---

<div class="post-metadata">

**Author:** ![Alexandre\_Heimburger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexandre_heimburger/32/2941_2.png) [@Alexandre\_Heimburger](https://discuss.elastic.co/u/Alexandre_Heimburger)\
**Post date:** [June 29, 2011, 10:36am UTC](https://discuss.elastic.co/t/ngram-question/4733/3 "2011-06-29T10:36:09Z")

</div>

OK. I got help on IRC and things are clearer now.

For your information, here is a GIST with a working example of NGram  
implementation. This can be used for an autocomplete box.

> <https://gist.github.com/aheimburger/1053618>

On Wed, Jun 29, 2011 at 11:38 AM, Paul Loy [keteracel@gmail.com](mailto:keteracel@gmail.com) wrote:

> Please gist ([https://gist.github.com/](https://gist.github.com/)) your example and we'll try to find  
> out what you've missed.
> 
> Thanks,
> 
> Paul.
> 
> On Wed, Jun 29, 2011 at 10:35 AM, alheim [alexheimburger@gmail.com](mailto:alexheimburger@gmail.com) wrote:
> 
> > Hello there,
> > 
> > I index a document containing the sentence "please search me".
> > 
> > I would like to retrieve this document by searching :
> > 
> > - please
> > 
> > - PlEasE
> > 
> > - pleas
> > 
> > - ase sear
> > 
> > - earch me
> > 
> > etc etc....
> > 
> > Some people told me that NGram was great and faster than prefixed  
> > queries.
> > 
> > But it does not work for me.
> > 
> > Could you please give me the analyzer configuration and the mapping  
> > for this use case ?
> > 
> > Thanks a lot.
> 
> ## --
> 
> Paul Loy  
> [paul@keteracel.com](mailto:paul@keteracel.com)  
> [http://uk.linkedin.com/in/paulloy](http://uk.linkedin.com/in/paulloy)

--  
Alexandre Heimburger  
R&D Manager  
blueKiwi Software  
tel : +33687880997  
email : [ahb@bluekiwi-software.com](mailto:ahb@bluekiwi-software.com)  
adress : 93 rue Vieille du Temple, 75003 Paris

What is blueKiwi? blueKiwi - the first Enterprise Social Software Suite in  
the world building professional networks on conversations and relationships

- helps large organizations increase their productivity, foster innovations  
and boost people satisfaction.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 29, 2011, 12:00pm UTC](https://discuss.elastic.co/t/ngram-question/4733/4 "2011-06-29T12:00:28Z")

</div>

Just a note on the name of the custom analyzers you created, calling them keyword might be confusing down the road, since they don't use the keyword tokenizer, but the standard one.

On Wednesday, June 29, 2011 at 1:36 PM, Alexandre Heimburger wrote:

> OK. I got help on IRC and things are clearer now.
> 
> For your information, here is a GIST with a working example of NGram implementation. This can be used for an autocomplete box.
> 
> [Ngram working sample · GitHub](https://gist.github.com/1053618)
> 
> On Wed, Jun 29, 2011 at 11:38 AM, Paul Loy \<[keteracel@gmail.com](mailto:keteracel@gmail.com) ([mailto:keteracel@gmail.com](mailto:keteracel@gmail.com))\> wrote:
> 
> > Please gist ([https://gist.github.com/](https://gist.github.com/)) your example and we'll try to find out what you've missed.
> > 
> > Thanks,
> > 
> > Paul.
> > 
> > On Wed, Jun 29, 2011 at 10:35 AM, alheim \<[alexheimburger@gmail.com](mailto:alexheimburger@gmail.com) ([mailto:alexheimburger@gmail.com](mailto:alexheimburger@gmail.com))\> wrote:
> > 
> > > Hello there,
> > > 
> > > I index a document containing the sentence "please search me".
> > > 
> > > I would like to retrieve this document by searching :
> > > 
> > > - please
> > > 
> > > - PlEasE
> > > 
> > > - pleas
> > > 
> > > - ase sear
> > > 
> > > - earch me
> > > 
> > > etc etc....
> > > 
> > > Some people told me that NGram was great and faster than prefixed  
> > > queries.
> > > 
> > > But it does not work for me.
> > > 
> > > Could you please give me the analyzer configuration and the mapping  
> > > for this use case ?
> > > 
> > > Thanks a lot.
> > 
> > ## --
> > 
> > Paul Loy  
> > [paul@keteracel.com](mailto:paul@keteracel.com) ([mailto:paul@keteracel.com](mailto:paul@keteracel.com))  
> > [http://uk.linkedin.com/in/paulloy](http://uk.linkedin.com/in/paulloy)
> 
> --  
> Alexandre Heimburger  
> R&D Manager  
> blueKiwi Software  
> tel : +33687880997  
> email : [ahb@bluekiwi-software.com](mailto:ahb@bluekiwi-software.com) ([mailto:ahb@bluekiwi-software.com](mailto:ahb@bluekiwi-software.com))  
> adress : 93 rue Vieille du Temple, 75003 Paris
> 
> What is blueKiwi? blueKiwi - the first Enterprise Social Software Suite in the world building professional networks on conversations and relationships - helps large organizations increase their productivity, foster innovations and boost people satisfaction.

---

<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, 4:02am UTC](https://discuss.elastic.co/t/ngram-question/4733/5 "2017-07-06T04:02:17Z")

</div>


