# Boost score for prefix matches

**URL:** <https://discuss.elastic.co/t/boost-score-for-prefix-matches/309384>\
**Category:** Elasticsearch\
**Created:** [July 12, 2022, 7:43am UTC](https://discuss.elastic.co/t/boost-score-for-prefix-matches/309384 "2022-07-12T07:43:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bogdanjsx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bogdanjsx/32/108181_2.png) [@bogdanjsx](https://discuss.elastic.co/u/bogdanjsx)\
**Post date:** [July 12, 2022, 7:43am UTC](https://discuss.elastic.co/t/boost-score-for-prefix-matches/309384/1 "2022-07-12T07:43:18Z")

</div>

Hello!  
I'm trying to implement something similar to a store search for products and I'm having a hard time boosting result score to order them in a specific manner.

Let's say I have a `name` field in my documents and I want to search on that field only.  
Assume I have the query string `crac` and the following 4 documents:

```auto
{name: "Crackers, 250g"}, // partial non-fuzzy match on first word
{name: "Some crackers, 250g", // partial non-fuzzy match on middle word
{name: "Crab, 100g"} // fuzzy match on first word 
{name: "Some crab, 100g"} // fuzzy match on middle word

```

Is there a way of ordering my results exactly in the order described above?  
That is, prioritize non-fuzzy matches, and then prioritize first word matches?

I'm currently using a standard analyzer with no success.  
I've read about edge\_ngram tokenizer, but that would not solve the first word dilemma.  
Migrating to a keyword tokenizer would allow first word matches but break subsequent ones matches.

Does anyone have an idea on how to achieve this?

---

<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:** [August 9, 2022, 7:43am UTC](https://discuss.elastic.co/t/boost-score-for-prefix-matches/309384/2 "2022-08-09T07:43:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
