Popular words

Does elasticsearch help track popular keywords? For example, in a certain period of time, I would like to know the keywords that are most often found in queries.

If elasticsearch doesn't have such a function, what would be a good way to implement it with elasticsearch?

Thanks!

+8
source share
4 answers

I don’t think there is a built-in way for this, but achieving this is pretty easy with facet

What you need to do:

  • Save all query keywords with timestamp in elasticsearch index
  • Run the match_all query filtered by the time interval you are interested in and apply the term facet to it

Unfortunately, I do not have time to write you an example, but this should lead you to a solution.

Here is an example:

// Demo index curl -XDELETE 'http://localhost:9200/queries/' curl -XPUT 'http://localhost:9200/queries/' // Add some data curl -XPUT 'http://localhost:9200/queries/query/1' -d ' { "date": "2013-02-19T12:57:23", "query": "Trying out ElasticSearch, so far so good?" }' curl -XPUT 'http://localhost:9200/queries/query/2' -d ' { "date": "2013-03-02T11:27:23", "query": "Lets give ElasticSearch another try" }' curl -XPUT 'http://localhost:9200/queries/query/3' -d ' { "date": "2013-04-02T08:27:23", "query": "OK, why dont we stick to SOLR?" }' curl -XPUT 'http://localhost:9200/queries/query/4' -d ' { "date": "2013-04-19T11:27:23", "query": "Couse ElasticSearch is so much cooler, its bonsai cool" }' // Query it curl -XGET 'http://localhost:9200/queries/query/_search?pretty=true' -d ' { "query" : { "filtered" : { "filter" : { "range" : { "date" : { "gte" : "2013-01-01T00:00:00", "lt" : "2013-04-01T00:00:00" } } }, "query" : { "match_all" : {} } } }, "facets": { "keywords": { "terms": { "field": "query" } } } } ' 

Adjust date range in query to see output changes

+12
source

The approved answer no longer works because Facets have been removed and replaced instead of aggregating terms .

+2
source

ES does not have this built-in, but there is a free Search Analytics service that launches Sematext (disclaimer: I work there), you can use it for this - see http://sematext.com/search-analytics/index.html

+1
source

Since FlexibleSearch does not have such a built-in function, you can use free services, such as google analyitc, and integrate them with the wrapper service that communicates with elasticsearch.

0
source

All Articles