teethblingbling
teethblingbling

Reputation: 11

How to get the word frequency of full-text search in elasticsearch

I have several documents like this:

    text: "hello, I am your friend"
    text: "hello, hello"
    text: "everybody said: hello hello"

In full-text search, I want to count the number of times the search term appears, For example, a search for "hello" will return 5 results. I tried to use aggregate search and the result returned was the number of documents.

How to construct such a query? Thanks.

Upvotes: 1

Views: 297

Answers (1)

ilvar
ilvar

Reputation: 5841

You can use explain API but you'd have to feed matching documents one by one. Look for the field with "description":"freq, occurrences of term within document"

Upvotes: 1

Related Questions