Skip to content
Advertisement

How to search by dict keys in ElasticSearch

I am new in elasticsearch and I need to write query described below

I have an elasticsearch index with documents like this one

Numbers mean entries of words in book

JavaScript

I want to search documents by words “cats” (not “cat”), “monkey” and e.g “mous”. How do I write query that will find “cat”, “monkey” and “mouse” in document and consider their values in counting score?

upd. Example: I have documents

JavaScript

Any ideas?

Advertisement

Answer

I don’t know if I understand correctly but you want to search for “cats” and return the doc words with the words “cat”, “monkey” and “mouse”.

Run this example I made and see if it works for you.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement