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 should
s 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.