ShenLei
ShenLei

Reputation: 587

How to periodically update ElasticSearch index? UPDATE or REBUILD?

Suppose there are fixed 1 million titles of articles to be indexed, and each article has two growing fields with "type": "rank_feature": view_count and favor_count. I have to update the value of counters every hours in order to boosting hot articles in search result.

Since the UPDATE operation in ES and Lucene is equivalent to search-delete-create, I wonder what is the proper solution in my case. Does UPDATE operation save unnecessary ANALYZE steps for those fixed titles?

Upvotes: 1

Views: 168

Answers (1)

xeraa
xeraa

Reputation: 10859

An update does not make your analysis more efficient — it still has to process the entire document again.

If you have 2 fields that change frequently and other fields that are more static, I'd restructure the documents to use parent/child:

  • The parent contains the static fields
  • The child has your 2 frequently changing fields

That way you can avoid the (re) analysis of documents as much as possible. This comes at the cost of some overhead at search-time, but should be manageable if you only have a single child.

Upvotes: 1

Related Questions