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 Rene Nederhand <re...@nederhand.net> on 2013/03/27 00:11:31 UTC

[ScriptUpdateProcessor] Params aren't being picked up from solrconfig

Hi,

I'm trying to use the new ScriptUpdateProcessor in trunk with a simple
Python script. Everything seems to work nicely, but....
none of the params I specify in solrconfig.xml are being picked up. The
error I'm getting is: "NameError: global name 'params' is not defined".

Am I doing something wrong? Is this a bug?

I'd appreciate any help on this.

Rene

*summary.py*
def processAdd(cmd):
    doc = cmd.solrDoc  # org.apache.solr.common.SolrInputDocument
    id = doc.getFieldValue('Identifier')
    logger.info('update-script#processAdd: id=' + id)

    # Get a configuration parameter
    to_field = params.get('to_field')
    doc.setField(to_field, doc.getFieldValue('abstract'))
    #logger.info('copy ' + from_field + ' to ' + to_field)

def processDelete(cmd):
    pass

def processMergeIndexes(cmd):
    pass

def processCommit(cmd):
    pass

def processRollback(cmd):
    pass

def finish():
    pass

*solrconfig.xml*
  <updateRequestProcessorChain name="script">
    <processor class="solr.StatelessScriptUpdateProcessorFactory">
      <str name="script">summarize.py</str>
    </processor>
    <!--  optional parameters passed to script -->
      <lst name="params">
        <str name="from_field">abstract</str>
        <str name="to_field">summary</str>
      </lst>
    <processor class="solr.LogUpdateProcessorFactory" />
    <processor class="solr.RunUpdateProcessorFactory" />
  </updateRequestProcessorChain>

*error*
Caused by: javax.script.ScriptException: NameError: global name 'params' is
not defined in <script> at line number 7
at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202)
at org.python.jsr223.PyScriptEngine.invokeFunction(PyScriptEngine.java:132)
at
org.apache.solr.update.processor.StatelessScriptUpdateProcessorFactory$ScriptUpdateProcessor.invokeFunction(StatelessScriptUpdateProcessorFactory.java:425)
... 29 more
Caused by: Traceback (most recent call last):
  File "<script>", line 7, in processAdd
NameError: global name 'params' is not defined

at org.python.core.Py.NameError(Py.java:252)
at org.python.core.PyFrame.getglobal(PyFrame.java:265)
at org.python.pycode._pyx1.processAdd$1(<script>:9)
at org.python.pycode._pyx1.call_function(<script>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyFunction.function___call__(PyFunction.java:406)
at org.python.core.PyFunction.__call__(PyFunction.java:401)
at org.python.core.PyFunction.__call__(PyFunction.java:391)
at org.python.core.PyFunction.__call__(PyFunction.java:386)
at org.python.jsr223.PyScriptEngine.invokeFunction(PyScriptEngine.java:126)
... 30 more

Re: [ScriptUpdateProcessor] Params aren't being picked up from solrconfig

Posted by Steve Rowe <sa...@gmail.com>.
Hi Rene,

Thanks for offering to help with wiki documentation.

You'll need to register on the wiki first, then tell us your wiki username, and we'll add you to ContributorsGroup, which will allow you to make edits.

Steve

On Mar 27, 2013, at 7:40 AM, Rene Nederhand <re...@nederhand.net> wrote:

> I cannot believe I've looked over this :}
> Thanks for helping me out. It works fine now.
> 
> I'd like to contribute to the wiki
> page<http://wiki.apache.org/solr/ScriptUpdateProcessor>and add a
> python example. So, if anyone could allow me write access or tell
> me how to do this without, I'd be happy to contribute.
> 
> On Wed, Mar 27, 2013 at 12:38 AM, Chris Hostetter
> <ho...@fucit.org>wrote:
> 
>> 
>> : none of the params I specify in solrconfig.xml are being picked up. The
>> : error I'm getting is: "NameError: global name 'params' is not defined".
>> 
>>        ...
>> 
>> :   <updateRequestProcessorChain name="script">
>> :     <processor class="solr.StatelessScriptUpdateProcessorFactory">
>> :       <str name="script">summarize.py</str>
>> :     </processor>
>> :     <!--  optional parameters passed to script -->
>> :       <lst name="params">
>> :         <str name="from_field">abstract</str>
>> :         <str name="to_field">summary</str>
>> :       </lst>
>> 
>> ...that list of "params" isn't inside the <processor> tag, so
>> StatelessScriptUpdateProcessorFactory doesn't know anything about it, so
>> it's not passing it to the ScriptEngineManager
>> 
>> 
>> -Hoss
>> 


Re: [ScriptUpdateProcessor] Params aren't being picked up from solrconfig

Posted by Rene Nederhand <re...@nederhand.net>.
I cannot believe I've looked over this :}
Thanks for helping me out. It works fine now.

I'd like to contribute to the wiki
page<http://wiki.apache.org/solr/ScriptUpdateProcessor>and add a
python example. So, if anyone could allow me write access or tell
me how to do this without, I'd be happy to contribute.

On Wed, Mar 27, 2013 at 12:38 AM, Chris Hostetter
<ho...@fucit.org>wrote:

>
> : none of the params I specify in solrconfig.xml are being picked up. The
> : error I'm getting is: "NameError: global name 'params' is not defined".
>
>         ...
>
> :   <updateRequestProcessorChain name="script">
> :     <processor class="solr.StatelessScriptUpdateProcessorFactory">
> :       <str name="script">summarize.py</str>
> :     </processor>
> :     <!--  optional parameters passed to script -->
> :       <lst name="params">
> :         <str name="from_field">abstract</str>
> :         <str name="to_field">summary</str>
> :       </lst>
>
> ...that list of "params" isn't inside the <processor> tag, so
> StatelessScriptUpdateProcessorFactory doesn't know anything about it, so
> it's not passing it to the ScriptEngineManager
>
>
> -Hoss
>

Re: [ScriptUpdateProcessor] Params aren't being picked up from solrconfig

Posted by Chris Hostetter <ho...@fucit.org>.
: none of the params I specify in solrconfig.xml are being picked up. The
: error I'm getting is: "NameError: global name 'params' is not defined".

	...

:   <updateRequestProcessorChain name="script">
:     <processor class="solr.StatelessScriptUpdateProcessorFactory">
:       <str name="script">summarize.py</str>
:     </processor>
:     <!--  optional parameters passed to script -->
:       <lst name="params">
:         <str name="from_field">abstract</str>
:         <str name="to_field">summary</str>
:       </lst>

...that list of "params" isn't inside the <processor> tag, so 
StatelessScriptUpdateProcessorFactory doesn't know anything about it, so 
it's not passing it to the ScriptEngineManager


-Hoss