简体   繁体   中英

How to set TTL to a particular field while updating it in Solr documents

A Solr document, let's say, has the schema that includes id and score . For every id I am updating a score based on an event trigger. However I want the score to become 0 or maybe gradually reduce after a week or so. Basically I need to set a TTL of about a week to that score field. Or I need the value of the score to be time-dependent somehow.

I am not setting TTL to the document because I want to retain the id but not the score , after a week. How can this be achieved??

I browsed a lot over internet, couldn't find the solution. That is why turned to the experts here in stack overflow.

Please help!!

The TTL is useful to automatically delete the doc after the TTL is reached, not to modify one field.

What you want to do is boost documents by time field, as explained here . The trick is recip function. You could further modify the expression to make the boost 0 when it's older than a week etc.

http://localhost:8983/solr/select?q={!boost b=recip(ms(NOW,manufacturedate_dt),3.16e-11,1,1)}ipod

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