You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by sarat chandra <sa...@gmail.com> on 2018/04/13 10:22:34 UTC

How to enable or disable component based on document field value in solrconfig.xml

 We have a use case where we need to populate uniq field from multiple
fields. Our solrconfig.xml file like below.

*<updateRequestProcessorChain name="updateProcess">*
*       <processor class="solr.CloneFieldUpdateProcessorFactory">*
* <str name="source">Code</str>*
* <str name="dest">FullCode</str>*
*       </processor>*
* <processor class="solr.CloneFieldUpdateProcessorFactory">*
* <str name="source">ExtendedCode</str>*
* <str name="dest">FullCode</str>*
*       </processor>*
*    <processor class="solr.ConcatFieldUpdateProcessorFactory">*
* <str name="delimiter">_</str>*
* <str name="fieldName">FullCode</str>*
* </processor>*
*    </updateRequestProcessorChain>*
The above configuration works fine if the document has both Code and
ExtendedCode. But For some of the documents we don't have ExtendedCode. For
those cases we are getting the error like Mandatory field not provided.

How we need to modify the configuration to support both scenarios.
i tried with below but no luck.
<processor class="solr.CloneFieldUpdateProcessorFactory"
enable="${ExtendedCode}" >
<str name="source">ExtendedCode</str>
<str name="dest">FullCode</str>
       </processor>


Depend on the Field value, i need to enable or disable the processor
dynamically.

how can i achieve this kind of behavior ? , Thanks

-- 
--with regards
SARAT CHANDRA

Re: How to enable or disable component based on document field value in solrconfig.xml

Posted by Erick Erickson <er...@gmail.com>.
Have you considered the StatelessScriptUpdateProcessorFactory? That
allows you to do pretty much anything you want.

Don't quite know whether TemplateUPdateProcessorFactory deals well
with empty fields or not, but it might be worth a shot.

And, of course, your ETL process could to that on the client side, but
sounds like that's not really a good option.

Best,
Erick

On Fri, Apr 13, 2018 at 3:22 AM, sarat chandra
<sa...@gmail.com> wrote:
>  We have a use case where we need to populate uniq field from multiple
> fields. Our solrconfig.xml file like below.
>
> *<updateRequestProcessorChain name="updateProcess">*
> *       <processor class="solr.CloneFieldUpdateProcessorFactory">*
> * <str name="source">Code</str>*
> * <str name="dest">FullCode</str>*
> *       </processor>*
> * <processor class="solr.CloneFieldUpdateProcessorFactory">*
> * <str name="source">ExtendedCode</str>*
> * <str name="dest">FullCode</str>*
> *       </processor>*
> *    <processor class="solr.ConcatFieldUpdateProcessorFactory">*
> * <str name="delimiter">_</str>*
> * <str name="fieldName">FullCode</str>*
> * </processor>*
> *    </updateRequestProcessorChain>*
> The above configuration works fine if the document has both Code and
> ExtendedCode. But For some of the documents we don't have ExtendedCode. For
> those cases we are getting the error like Mandatory field not provided.
>
> How we need to modify the configuration to support both scenarios.
> i tried with below but no luck.
> <processor class="solr.CloneFieldUpdateProcessorFactory"
> enable="${ExtendedCode}" >
> <str name="source">ExtendedCode</str>
> <str name="dest">FullCode</str>
>        </processor>
>
>
> Depend on the Field value, i need to enable or disable the processor
> dynamically.
>
> how can i achieve this kind of behavior ? , Thanks
>
> --
> --with regards
> SARAT CHANDRA