# Search and Ngram tokenizer

**URL:** https://discuss.elastic.co/t/search-and-ngram-tokenizer/7164
**Category:** Elasticsearch
**Created:** [March 28, 2012, 10:46am UTC](https://discuss.elastic.co/t/search-and-ngram-tokenizer/7164 "2012-03-28T10:46:34Z")
**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: [March 28, 2012, 10:46am UTC](https://discuss.elastic.co/t/search-and-ngram-tokenizer/7164/1 "2012-03-28T10:46:34Z")

</div>

Hi,

I'm using a ngram tokenizer to index my content (user's name). Search is  
done in a suggestion box.

Example :

I search "gory" and I find "gregory faw", "gregory doe", and "John Gory".

Would it be possible to increase the score of John Gory since its lastname  
matches the whole search term ?

The problem is that if I know that I want to select John Gory, and if there  
are lot of gregory, he will never be suggested.

Thanks for your help

Alheim

---

<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: [March 29, 2012, 12:02pm UTC](https://discuss.elastic.co/t/search-and-ngram-tokenizer/7164/2 "2012-03-29T12:02:42Z")

</div>

You can index the field twice using multi field mapping, once using ngram,  
and once using something like the default standard analyzer, and then,  
search on both fields, boosting the one that uses the standard analyzer.

On Wed, Mar 28, 2012 at 12:46 PM, Alexandre Heimburger \<  
[alexheimburger@gmail.com](mailto:alexheimburger@gmail.com)\> wrote:

> Hi,
> 
> I'm using a ngram tokenizer to index my content (user's name). Search is  
> done in a suggestion box.
> 
> Example :
> 
> I search "gory" and I find "gregory faw", "gregory doe", and "John Gory".
> 
> Would it be possible to increase the score of John Gory since its lastname  
> matches the whole search term ?
> 
> The problem is that if I know that I want to select John Gory, and if  
> there are lot of gregory, he will never be suggested.
> 
> Thanks for your help
> 
> Alheim

---

<div class="post-metadata">

### Author: ![alheim](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@alheim](https://discuss.elastic.co/u/alheim)
#### Post date: [March 29, 2012, 1:39pm UTC](https://discuss.elastic.co/t/search-and-ngram-tokenizer/7164/3 "2012-03-29T13:39:07Z")

</div>

awesome. Thx !

On Thu, Mar 29, 2012 at 2:02 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> You can index the field twice using multi field mapping, once using ngram,  
> and once using something like the default standard analyzer, and then,  
> search on both fields, boosting the one that uses the standard analyzer.
> 
> On Wed, Mar 28, 2012 at 12:46 PM, Alexandre Heimburger \<  
> [alexheimburger@gmail.com](mailto:alexheimburger@gmail.com)\> wrote:
> 
> > Hi,
> > 
> > I'm using a ngram tokenizer to index my content (user's name). Search is  
> > done in a suggestion box.
> > 
> > Example :
> > 
> > I search "gory" and I find "gregory faw", "gregory doe", and "John Gory".
> > 
> > Would it be possible to increase the score of John Gory since its  
> > lastname matches the whole search term ?
> > 
> > The problem is that if I know that I want to select John Gory, and if  
> > there are lot of gregory, he will never be suggested.
> > 
> > Thanks for your help
> > 
> > Alheim

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

blueKiwi is the innovation leader in Enterprise Social Software. Our  
solutions enable enterprises worldwide to engage and interact with their  
internal and external social networks in multiple business domains.  
blueKiwi has been consistently recognized by Gartner Inc. as a visionary  
provider since 2007.

---

<div class="post-metadata">

### Author: ![Jamie\_Brough](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@Jamie\_Brough](https://discuss.elastic.co/u/Jamie_Brough)
#### Post date: [March 29, 2012, 3:34pm UTC](https://discuss.elastic.co/t/search-and-ngram-tokenizer/7164/4 "2012-03-29T15:34:59Z")

</div>

Alheim,

I just posted a very similar question - the following thread may be useful.  
The mapping and query in the original post works perfectly for me:

[http://elasticsearch-users.115913.n3.nabble.com/Question-about-multi-field-and-edge-ngram-td3800000.html](http://elasticsearch-users.115913.n3.nabble.com/Question-about-multi-field-and-edge-ngram-td3800000.html)

On Thursday, 29 March 2012 14:39:07 UTC+1, Alexandre Heimburger wrote:

> awesome. Thx !
> 
> On Thu, Mar 29, 2012 at 2:02 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > You can index the field twice using multi field mapping, once using  
> > ngram, and once using something like the default standard analyzer, and  
> > then, search on both fields, boosting the one that uses the standard  
> > analyzer.
> > 
> > On Wed, Mar 28, 2012 at 12:46 PM, Alexandre Heimburger \<  
> > [alexheimburger@gmail.com](mailto:alexheimburger@gmail.com)\> wrote:
> > 
> > > Hi,
> > > 
> > > I'm using a ngram tokenizer to index my content (user's name). Search is  
> > > done in a suggestion box.
> > > 
> > > Example :
> > > 
> > > I search "gory" and I find "gregory faw", "gregory doe", and "John  
> > > Gory".
> > > 
> > > Would it be possible to increase the score of John Gory since its  
> > > lastname matches the whole search term ?
> > > 
> > > The problem is that if I know that I want to select John Gory, and if  
> > > there are lot of gregory, he will never be suggested.
> > > 
> > > Thanks for your help
> > > 
> > > Alheim
> 
> --  
> Alexandre Heimburger  
> VP Engineering  
> blueKiwi Software  
> tel : +33687880997  
> email : [ahb@bluekiwi-software.com](mailto:ahb@bluekiwi-software.com)  
> adress : 93 rue Vieille du Temple, 75003 Paris
> 
> * * *
> 
> blueKiwi is the innovation leader in Enterprise Social Software. Our  
> solutions enable enterprises worldwide to engage and interact with their  
> internal and external social networks in multiple business domains.  
> blueKiwi has been consistently recognized by Gartner Inc. as a visionary  
> provider since 2007.

---

<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:34am UTC](https://discuss.elastic.co/t/search-and-ngram-tokenizer/7164/5 "2017-07-06T03:34:12Z")

</div>


