# Boosting exact matches in edgengram search

**URL:** <https://discuss.elastic.co/t/boosting-exact-matches-in-edgengram-search/12058>\
**Category:** Elasticsearch\
**Created:** [May 21, 2013, 5:39pm UTC](https://discuss.elastic.co/t/boosting-exact-matches-in-edgengram-search/12058 "2013-05-21T17:39:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chad\_Kouse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chad_kouse/32/2290_2.png) [@Chad\_Kouse](https://discuss.elastic.co/u/Chad_Kouse)\
**Post date:** [May 21, 2013, 5:39pm UTC](https://discuss.elastic.co/t/boosting-exact-matches-in-edgengram-search/12058/1 "2013-05-21T17:39:09Z")

</div>

If I search for "liz" I need an exact match of "liz" to score higher than  
"lizz"

Can I do this all in one query or do I need to run a separate query to look  
for an exact match?

--chad

--  
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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 23, 2013, 10:03am UTC](https://discuss.elastic.co/t/boosting-exact-matches-in-edgengram-search/12058/2 "2013-05-23T10:03:52Z")

</div>

I would expect it to do this automatically, because "liz" has fewer tokens  
than "lizz". However, to ensure that it works the way you want, you can  
index the field as a multi-field, using (eg) the standard analyzer on the  
main field, and your edge-ngrams on another field.

The use a bool query which matches against both fields - you'll find docs  
that match the ngrams, but docs with exact matches will be boosted by the  
clause on the main field.

clint

On 21 May 2013 19:39, Chad Kouse [chad.kouse@gmail.com](mailto:chad.kouse@gmail.com) wrote:

> If I search for "liz" I need an exact match of "liz" to score higher than  
> "lizz"
> 
> Can I do this all in one query or do I need to run a separate query to  
> look for an exact match?
> 
> --chad
> 
> --  
> 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).

--  
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:** ![btiernay](https://avatars.discourse-cdn.com/v4/letter/b/bb73d2/32.png) [@btiernay](https://discuss.elastic.co/u/btiernay)\
**Post date:** [July 4, 2013, 1:10pm UTC](https://discuss.elastic.co/t/boosting-exact-matches-in-edgengram-search/12058/3 "2013-07-04T13:10:12Z")

</div>

Hi Clint,

We are encountering the same issue. This sounds like a bug. Should we file  
a ticket against ES?

Thanks,

Bob

On Thursday, 23 May 2013 06:03:52 UTC-4, Clinton Gormley wrote:

> I would expect it to do this automatically, because "liz" has fewer tokens  
> than "lizz". However, to ensure that it works the way you want, you can  
> index the field as a multi-field, using (eg) the standard analyzer on the  
> main field, and your edge-ngrams on another field.
> 
> The use a bool query which matches against both fields - you'll find docs  
> that match the ngrams, but docs with exact matches will be boosted by the  
> clause on the main field.
> 
> clint
> 
> On 21 May 2013 19:39, Chad Kouse \<[chad....@gmail.com](mailto:chad....@gmail.com) \<javascript:\>\> wrote:
> 
> > If I search for "liz" I need an exact match of "liz" to score higher than  
> > "lizz"
> > 
> > Can I do this all in one query or do I need to run a separate query to  
> > look for an exact match?
> > 
> > --chad
> > 
> > --  
> > 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).

--  
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:** ![cgendreau](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cgendreau/32/2204_2.png) [@cgendreau](https://discuss.elastic.co/u/cgendreau)\
**Post date:** [July 15, 2013, 8:28pm UTC](https://discuss.elastic.co/t/boosting-exact-matches-in-edgengram-search/12058/4 "2013-07-15T20:28:36Z")

</div>

I was also expecting this to work without using multi-field. Am I missing something?

---

<div class="post-metadata">

**Author:** ![totessusan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/totessusan/32/13028_2.png) [@totessusan](https://discuss.elastic.co/u/totessusan)\
**Post date:** [March 20, 2017, 9:01pm UTC](https://discuss.elastic.co/t/boosting-exact-matches-in-edgengram-search/12058/5 "2017-03-20T21:01:53Z")

</div>

It's 2017, and I'm still have the same problem? Did anyone figure this out without using multi-field? Or is that the only way? I'd really love to know! Thanks in advance!

---

<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 5, 2017, 10:02pm UTC](https://discuss.elastic.co/t/boosting-exact-matches-in-edgengram-search/12058/6 "2017-07-05T22:02:04Z")

</div>


