Solr split joined dates to multivalue field

后端 未结 1 1443
遇见更好的自我
遇见更好的自我 2021-01-25 09:26

I use an application that stores data to solr. Unfortunately this one can only write single-values to solr. But some of the data have multiple date-values. So to search them I n

1条回答
  •  孤街浪徒
    2021-01-25 10:15

    StatelessScriptUpdateProcessorFactory that enables the use of update processors implemented as scripts during update request.
    When Solr update the document then we get the field value in which multiple dates are coming in StatelessScriptUpdateProcessorFactory. We split the value and put into new field.
    Lets say multiDate is the string field in which multiple dates are coming and date is multivalued field having tdate as field type.

    
    
    

    Below is the sample update-script.js.

    function processAdd(cmd) {
        doc = cmd.solrDoc;
        multiDate = doc.getFieldValue("multiDate").toString();
        dates = multiDate.split("\\$");
        doc.setField("date",dates);
    
    }
    function processDelete(cmd) {
      // no-op
    }
    
    function processMergeIndexes(cmd) {
      // no-op
    }
    
    function processCommit(cmd) {
      // no-op
    }
    
    function processRollback(cmd) {
      // no-op
    }
    
    function finish() {
      // no-op
    }
    

    Add the StatelessScriptUpdateProcessorFactory processor to the updateRequestProcessorChain in solrconfig.xml.

    
       updateProcessor.js
     
    

    l

    0 讨论(0)
提交回复
热议问题