Append some kind of a phrase to text field while keeping the search score

Elasticsearch 6.3. Let's assume I have an index called food (I would like to keep it as one index), which stores a name in two languages. For now I have search that can considers both full (scored higher) and ngram results of chosen languages - basically a bool query with shoulds for full/ngram fields in chosen languages. E.g. full apple is scored higher than ngram apple in apple sauce.

Now I would like to add a possibility for the user to append predefined type words while keeping the score of full/ngram results. For example fruit apple should have the same (or at least very similar) score as mentioned apple, similar thing for meat bacon, meat bac with the same score as bac etc.

One could say I could just strip fruit before passing it to the Elasticsearch query, but the problem is that there could be fruit of whatever tree record too.

So, what would be the recommended way of dealing with this? I'm sure that adding an additional analyzer to both full field and ngram field, but which one would be the most suitable one? I looked through all and the most suitable one looks like synonyms, but if I'm not mistaken I would need to add a synonym for each word separately, is there anything else I'm missing? The type field is also indexed (in one language for now, but I can add the second), so it could be used, if possible.

Bump.

And a TLDR version:
I'd like "someword fullscoreword" to have the same (boosted in the query) score as "fullscoreword" and "someword fullsc" to have the same score as "fullsc" without removing the word before using it in the query.

If you don't want "someword" to affect the score, you need to exclude it for that field by putting it into a Stopword filter. That also means you cannot search for that word in that field anymore. You can't have your cake and eat it.

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