4

I am trying to use Solr auto-delete feature with solr-6. I have made the following changes in my managed-schema.xml and solrconfig.xml.

managed-schema

<!--expiration date field-->
<field name="eDate" type="date" multiValued="false" indexed="true" stored="true"/>
<field name="ttl" type="string" multiValued="false" indexed="true" stored="true" default="+90SECONDS"/>

solrconfig

<processor class="solr.processor.DocExpirationUpdateProcessorFactory">
    <int name="autoDeletePeriodSeconds">30</int>
    <str name="ttlFieldName">ttl</str>
    <str name="expirationFieldName">eDate</str>
</processor>

I am able to use auto delete feature as expected if I explicitly set the ttl field either in the incoming document or if I set the ttl request parameter in the update request. However, I want to use a default value for ttl as specified in the managed-schema if I do not explicitly set the ttl field. When I try this, ttl field is generated with the default value but the corresponding eDate field is not generated.

Is it possible to do what I am trying to do? If yes, then how can I do this? Please leave a comment if you need any further details.

1 Answers1

3

I couldn't make it working via default param in field description, but I make it working via adding solr.DefaultValueUpdateProcessorFactory

In my update chain I have this:

    <processor class="solr.DefaultValueUpdateProcessorFactory">
        <str name="fieldName">ttl</str>
        <str name="value">+15SECONDS</str>
    </processor>
    <processor class="solr.processor.DocExpirationUpdateProcessorFactory">
        <int name="autoDeletePeriodSeconds">5</int>
        <str name="ttlFieldName">ttl</str>
        <str name="expirationFieldName">eDate</str>
    </processor>

I change values to have a quicker test :) Link to the working code

Mysterion
  • 9,050
  • 3
  • 30
  • 52
  • Any idea why it is not working for default field directly in the schema? Because we do not want to pass the TTL for every document from our code. I think adding "default" keyword in the field property should internally be triggering this update processor? – GothamGirl Jan 18 '17 at 09:01
  • 1
    my answer do not require to pass TTL for every document. have no idea why it's not working through schema param – Mysterion Jan 18 '17 at 09:22
  • @Mysterion I am storing documents using parent child relationship. My ttl and eDate fields are only generated for parent documents and not child documents. Do you know a way to remedy this? Update request is sent via java solr client's commit method. – shubham jain Jan 19 '17 at 08:38
  • plz create another question about default field values for child docs with code, etc – Mysterion Jan 19 '17 at 09:24