Boost score for prefix matches

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:

{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?

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