[ 
https://issues.apache.org/jira/browse/SOLR-10865?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16046648#comment-16046648
 ] 

Amrit Sarkar commented on SOLR-10865:
-------------------------------------

[~shalinmangar] agreed. This is not working after *SOLR-9530* where certain 
adjustments made in *UpdateRequestProcessorChain.java* to make sure inform(...) 
works for AtomicURP (related to _LazyPluginHolder_ in PluginBag.java_). I 
didn't make the changes myself but I see what are you saying and we may have 
gone wrong there.

patch snippet from SOLR-9530 =>
{code}
diff --git 
a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
 
b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
index 0ed626cb0f..05d1a5ae3f 100644
--- 
a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
+++ 
b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
@@ -28,6 +28,8 @@ import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.StrUtils;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.core.PluginBag;
 import org.apache.solr.core.PluginInfo;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.request.SolrQueryRequest;
@@ -271,9 +273,13 @@ public final class UpdateRequestProcessorChain implements 
PluginInfoInitialized
       UpdateRequestProcessorFactory p = core.getUpdateProcessors().get(s);
       if (p == null) {
         try {
-          p = core.createInstance(s + "UpdateProcessorFactory", 
UpdateRequestProcessorFactory.class,
-              "updateProcessor", null, core.getMemClassLoader());
-          core.getUpdateProcessors().put(s, p);
+          PluginInfo pluginInfo = new PluginInfo("updateProcessor",
+              Utils.makeMap("name", s,
+                  "class", s + "UpdateProcessorFactory",
+                  "runtimeLib", "true"));
+
+          PluginBag.PluginHolder<UpdateRequestProcessorFactory> pluginHolder = 
core.getUpdateProcessors().createPlugin(pluginInfo);
+          core.getUpdateProcessors().put(s, p = pluginHolder.get());
         } catch (SolrException e) {
         }
         if (p == null)
{code}

I don't recall the exact reason behind this, but will surely look into it.

> parameter processor=Template doesn't invoke TemplateUpdateProcessorFactory.
> ---------------------------------------------------------------------------
>
>                 Key: SOLR-10865
>                 URL: https://issues.apache.org/jira/browse/SOLR-10865
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: update
>    Affects Versions: master (7.0)
>            Reporter: Amrit Sarkar
>         Attachments: SOLR-10865.patch, SOLR-10865.patch
>
>
> Ref docs::
> {quote}
> 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.
> {quote}
> Sample curl::
> {code}
> 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"}'
> {code}
> I am receiving exception::
> {code}
> <?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>
> {code}
> {code}
> 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)
> {code}
> I looked into how the testclass has been created::
> TemplateUpdateProcessorTest::
> {code}
>   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"));
>   }
> {code}
> *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.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to