Thanks for giving multiple options , I ll try them out both ,but last time I checked, having "+60SECONDS" as the default value for ttl was giving me an invalid date format exception...., I am assuming that would only be the case if I use it with the default mechanism in schema.xml, but not when we use the solr.DefaultValueUpdateProcessorFactory ?
On Wed, Feb 4, 2015 at 1:56 PM, Chris Hostetter <hossman_luc...@fucit.org> wrote: > > : <processor > : class="solr.processor.DocExpirationUpdateProcessorFactory"> > : <int name="autoDeletePeriodSeconds">30</int> > : <str name="ttlFieldName">ttl</str> > : <str name="expirationFieldName">expire_at</str> > : </processor> > > ... > > : And I have included the following in my schema.xml > : > : <field name="ttl" type="date" indexed="true" stored="true" > : default="NOW+60SECONDS" multiValued="false"/> > > there are a couple of problems here... > > : As you can see I am setting the time to live to be 60 seconds and > checking > : to delete every 30 seconds, when I insert a document , and check after a > : minute or couple or an hour it never gets deleted. > > first off: you aren't actaully setting the ttl to "60 seconds" you are > setting the ttl to be a fixed moment in time which is 60 seconds from when > the doc is written to the index -- basically you are eliminating hte need > for having a ttl field/param at all and saying "this is *exactly* when the > document should expire". > > if that's what you want to do, just elimintae the ttleFieldName everywhere > in your schema.xml and solrconfig.xml and setup expire_at in your > schema.xml with a default="NOW+60SECONDS" and you'll probably be good to > go. > > second... > > : what might be the issue here ? Please note that the expire_at field is > : never getting generated in the Solr document as can be seen below. > > ...even if you redefined your ttl field to look like this... > > <field name="ttl" type="string" default="+60SECONDS" /> > > ...the expire_at still wouldn't be populated by the processor because > schema field "default" values are populated *after* the processors run -- > so when the DocExpirationUpdateProcessorFactory sees the documents being > added, it has no idea that they all have a default ttl, so it doesn't know > that you want it to compute an expire_at for you. > > instead of using default="" in the schema, you can use the > DefaultValueUpdateProcessorFactory to assign it *before* the > DocExpirationUpdateProcessorFactory sees the doc... > > <processor class="solr.DefaultValueUpdateProcessorFactory"> > <str name="fieldName">ttl</str> > <str name="value">+60SECONDS</str> > </processor> > > > > > -Hoss > http://www.lucidworks.com/ >