# Searching query return results based on word frequency/term vectors

**URL:** <https://discuss.elastic.co/t/searching-query-return-results-based-on-word-frequency-term-vectors/129524>\
**Category:** Elasticsearch\
**Created:** [April 25, 2018, 3:19pm UTC](https://discuss.elastic.co/t/searching-query-return-results-based-on-word-frequency-term-vectors/129524 "2018-04-25T15:19:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandbar\_shark](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@sandbar\_shark](https://discuss.elastic.co/u/sandbar_shark)\
**Post date:** [April 25, 2018, 3:19pm UTC](https://discuss.elastic.co/t/searching-query-return-results-based-on-word-frequency-term-vectors/129524/1 "2018-04-25T15:19:37Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 23, 2018, 3:19pm UTC](https://discuss.elastic.co/t/searching-query-return-results-based-on-word-frequency-term-vectors/129524/2 "2018-05-23T15:19:51Z")

</div>

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