Searching query return results based on word frequency/term vectors

So I have an index that has multiple documents, each document being sentences of text. For example:

Doc 1: "the cat in the hat"
Doc 2: "feed your cat lots of fish for a cat"

So I indexed them with term vectors, so I can search and see the word frequency for each document:

Doc 1:
"cat": 1
"hat": 1

Doc 2:
"feed": 1
"cat": 2
"lots": 1
"fish": 1

So I want to be able to search this index so that if I say:

"What do I feed my cat"

This should return Doc 2, because it found feed once and cat twice in Doc 2 but only cat once in Doc 1, thus giving Doc 2 three points and Doc 1 only one point.

Doc 1: score of 1 (cat)
Doc 2: score of 3 (feed,cat x2).

Is there a way to do this in Elasticsearch? Thanks!

1 Like

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