简体   繁体   中英

How expiration field values for documents from a “time to live” (TTL) is calculated in Solr?

I went through the Java-doc @ DocExpirationUpdateProcessorFactory . It says:

The DocExpirationUpdateProcessorFactory provides two features related to the "expiration" of documents which can be used individually, or in combination:

  • Computing expiration field values for documents from a "time to live" (TTL)
  • Periodically delete documents from the index based on an expiration field

But it didn't specify how expirationField values are calculated from ttl field.

Anybody can help to understand how its calculated?

ttlFieldName - Name of a field this process should look for in each document processed, defaulting to _ttl_ . If the specified field name exists in a document, the document field value will be parsed as a Date Math Expression relative to NOW and the result will be added to the document using the expirationFieldName .

This means that you can use terms like +2 HOURS in the _ttl_ field to make the document expire in two hours from when it was indexed. This date value will then be stored in the expirationFieldName field.

From Cloudera's documentation about the introduction of the feature :

Current Time is: 2016-10-26 20:14:00

_ttl_ is defined as: +2HOURS

This will result in an expiration value of 2016-10-26 22:14:00

There are also more examples in Lucidworks description of the feature :

{ "id"             : "live_2_minutes_b",
  "time_to_live_s" : "+120SECONDS"            
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM