Question

I have partial matching of words working with ngrams. How can I modify the mapping to always favor exact matches over ngram tokens? I do not want to modify the query. One search box will search multiple types, each with their own fields.

For example, lets say I'm searching job titles, one person has a title of "field engineer", the other a title of "engine technician". If a user searches for "engine", I'd want ES to return the latter as more relevant.

I'm using this mapping almost verbatim: https://stackoverflow.com/a/19874785/978622 -Exception: I'm using an ngram with min of 3 and max of 11 instead of edge ngram

Is it possible to apply a boost/function score to an analyzer? If so I'll apply both the "full_name" and "partial_name" analyzers to my index as well and boost the first.

Edit: I'm using ElasticSearch 1.1.1 and Nest 1.0.0 beta

Was it helpful?

Solution

I don't believe there is anyway to apply boosting to an analyzer as you're suggesting.

One thing you can try, is to use the multi field type in your mapping. You could then apply your partial_name analyzer to one version of the field, and your full_name analyzer to the other version.

With this mapping, you could query both fields differently, but combined (perhaps in a bool query), and apply a boost to the query that is being conducted on the full_name analyzed field.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top