Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-10865

parameter processor=Template doesn't invoke TemplateUpdateProcessorFactory.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.0
    • Fix Version/s: None
    • Component/s: update
    • Labels:
      None

      Description

      Ref docs::

      The TemplateUpdateProcessorFactory can be used to add new fields to documents based on a template pattern.
      This can be used directly in a request without any configuration. To enable this processor, use the parameter processor=Template.

      Sample curl::

      curl -X POST -H 'Content-Type:application/json' 'http://localhost:8983/solr/gettingstarted/update/json/docs?processor=Template&Template.field=fullName_s:AmritSarkar&commit=true' --data-binary '{"id": 1,"title": "titleA"}'
      

      I am receiving exception::

      <?xml version="1.0" encoding="UTF-8"?>
      <response>
      <lst name="responseHeader"><int name="status">400</int><int name="QTime">3</int></lst><lst name="error"><lst name="metadata"><str name="error-class">org.apache.solr.common.SolrException</str><str name="root-error-class">org.apache.solr.common.SolrException</str></lst><str name="msg">No such processor Template</str><int name="code">400</int></lst>
      </response>
      
      ERROR - 2017-06-10 07:39:51.598; [c:gettingstarted s:shard2 r:core_node1 x:gettingstarted_shard2_replica_n1] org.apache.solr.common.SolrException; org.apache.solr.common.SolrException: No such processor Template
      	at org.apache.solr.update.processor.UpdateRequestProcessorChain.getReqProcessors(UpdateRequestProcessorChain.java:286)
      	at org.apache.solr.update.processor.UpdateRequestProcessorChain.constructChain(UpdateRequestProcessorChain.java:235)
      

      I looked into how the testclass has been created::

      TemplateUpdateProcessorTest::

        public void testSimple() throws Exception {
          AddUpdateCommand cmd = new AddUpdateCommand(new LocalSolrQueryRequest(null,
              new ModifiableSolrParams()
                  .add("processor", "Template")
                  .add("Template.field", "id:${firstName}_${lastName}")
                  .add("Template.field", "another:${lastName}_${firstName}")
                  .add("Template.field", "missing:${lastName}_${unKnown}")
          ));
          cmd.solrDoc = new SolrInputDocument();
          cmd.solrDoc.addField("firstName", "Tom");
          cmd.solrDoc.addField("lastName", "Cruise");
      
          new TemplateUpdateProcessorFactory().getInstance(cmd.getReq(), new SolrQueryResponse(), null).processAdd(cmd);
          assertEquals("Tom_Cruise", cmd.solrDoc.getFieldValue("id"));
          assertEquals("Cruise_Tom", cmd.solrDoc.getFieldValue("another"));
          assertEquals("Cruise_", cmd.solrDoc.getFieldValue("missing"));
        }
      

      There is no test to check whether processor=Template works or not, TemplateUpdateProcessorFactory() object is EXPLICITLY created to getInstance and do processing on the updates.

        Attachments

        1. SOLR-10865.patch
          4 kB
          Amrit Sarkar
        2. SOLR-10865.patch
          3 kB
          Amrit Sarkar
        3. SOLR-10865.patch
          3 kB
          Amrit Sarkar

          Issue Links

            Activity

              People

              • Assignee:
                noble.paul Noble Paul
                Reporter:
                sarkaramrit2@gmail.com Amrit Sarkar
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: