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 Tom LAMPERT <t....@laboquantup.eu> on 2014/10/22 19:50:26 UTC
StatelessScriptUpdateProcessorFactory Access to Solr
Core/schema/analyzer etc
Hello,
I am attempting to create a script (java script) using the StatelessScriptUpdateProcessorFactory feature of solr but I am blocked on how to access the current core instance (ultimately to access it's schema)? In the wikipedia example the input document is accessible using doc = cmd.solrDoc but no other information is given. The aim of the script is to apply any filters/tokenisers to the input fields before solr indexes them so that the stored values are those after processing, not the original data. Any tips would be gratefully received as I cannot find any info on the API for this framework...
Kind regards,
Tom
Re: StatelessScriptUpdateProcessorFactory Access to Solr
Core/schema/analyzer etc
Posted by Tom LAMPERT <t....@laboquantup.eu>.
Thank you, embarrassingly I had not looked at that doc.
And thank you to the other repliers.
________________________________________
From: Chris Hostetter <ho...@fucit.org>
Sent: 22 October 2014 20:38
To: solr-user@lucene.apache.org
Subject: Re: StatelessScriptUpdateProcessorFactory Access to Solr Core/schema/analyzer etc
: I am attempting to create a script (java script) using the
: StatelessScriptUpdateProcessorFactory feature of solr but I am blocked
: on how to access the current core instance (ultimately to access it's
: schema)? In the wikipedia example the input document is accessible using
: doc = cmd.solrDoc but no other information is given. The aim of the
Have you looked at the javadocs for the Factory?
https://lucene.apache.org/solr/4_10_0/solr-core/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.html
It notes exactly what objects are in global scope for each script -
notably you have access to the SolrQueryRequest from which you can call
getCore() or getSchema().
It also notes that the methods in each script need to implement the
UpdateRequestProcessor - which means the "cmd" object passed to each
method is an instance of (a subclass of) "UpdateCommand" - so you can also
use cmd.getReq() to access the SolrQueryRequest even if you aren't sure
how to get to global variables in your scripting language you are using.
-Hoss
http://www.lucidworks.com/
Re: StatelessScriptUpdateProcessorFactory Access to Solr
Core/schema/analyzer etc
Posted by Chris Hostetter <ho...@fucit.org>.
: I am attempting to create a script (java script) using the
: StatelessScriptUpdateProcessorFactory feature of solr but I am blocked
: on how to access the current core instance (ultimately to access it's
: schema)? In the wikipedia example the input document is accessible using
: doc = cmd.solrDoc but no other information is given. The aim of the
Have you looked at the javadocs for the Factory?
https://lucene.apache.org/solr/4_10_0/solr-core/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.html
It notes exactly what objects are in global scope for each script -
notably you have access to the SolrQueryRequest from which you can call
getCore() or getSchema().
It also notes that the methods in each script need to implement the
UpdateRequestProcessor - which means the "cmd" object passed to each
method is an instance of (a subclass of) "UpdateCommand" - so you can also
use cmd.getReq() to access the SolrQueryRequest even if you aren't sure
how to get to global variables in your scripting language you are using.
-Hoss
http://www.lucidworks.com/
Re: StatelessScriptUpdateProcessorFactory Access to Solr Core/schema/analyzer
etc
Posted by Shawn Heisey <ap...@elyograg.org>.
On 10/23/2014 2:47 AM, Erik Hatcher wrote:
> Ummm… see slides 10 and 11 here: http://www.slideshare.net/erikhatcher/solr-indexing-and-analysis-tricks
>
> So yes, you can do analysis tricks in an update script. And it’s incredibly useful and powerful! :)
That's pretty amazing. I would not have imagined that this kind of
crossover would be possible. Thanks for the info!
Shawn
Re: StatelessScriptUpdateProcessorFactory Access to Solr Core/schema/analyzer etc
Posted by Erik Hatcher <er...@gmail.com>.
On Oct 22, 2014, at 3:27 PM, Shawn Heisey <ap...@elyograg.org> wrote:
> On 10/22/2014 11:50 AM, Tom LAMPERT wrote:
>> I am attempting to create a script (java script) using the StatelessScriptUpdateProcessorFactory feature of solr but I am blocked on how to access the current core instance (ultimately to access it's schema)? In the wikipedia example the input document is accessible using doc = cmd.solrDoc but no other information is given. The aim of the script is to apply any filters/tokenisers to the input fields before solr indexes them so that the stored values are those after processing, not the original data. Any tips would be gratefully received as I cannot find any info on the API for this framework...
>
> I would guess that you'd need to be writing Java code to have this kind
> of detail, not javascript. The info in the other replies you received
> is talking about Java code.
>
> Javascript would not be able to execute the analysis on the input anyway
> -- that's all Java as well.
Ummm… see slides 10 and 11 here: http://www.slideshare.net/erikhatcher/solr-indexing-and-analysis-tricks
So yes, you can do analysis tricks in an update script. And it’s incredibly useful and powerful! :)
Erik
Re: StatelessScriptUpdateProcessorFactory Access to Solr Core/schema/analyzer
etc
Posted by Shawn Heisey <ap...@elyograg.org>.
On 10/22/2014 11:50 AM, Tom LAMPERT wrote:
> I am attempting to create a script (java script) using the StatelessScriptUpdateProcessorFactory feature of solr but I am blocked on how to access the current core instance (ultimately to access it's schema)? In the wikipedia example the input document is accessible using doc = cmd.solrDoc but no other information is given. The aim of the script is to apply any filters/tokenisers to the input fields before solr indexes them so that the stored values are those after processing, not the original data. Any tips would be gratefully received as I cannot find any info on the API for this framework...
I would guess that you'd need to be writing Java code to have this kind
of detail, not javascript. The info in the other replies you received
is talking about Java code.
Javascript would not be able to execute the analysis on the input anyway
-- that's all Java as well.
Thanks,
Shawn
Re: StatelessScriptUpdateProcessorFactory Access to Solr
Core/schema/analyzer etc
Posted by Ramzi Alqrainy <ra...@gmail.com>.
In the below script you have access to several Solr objects, allowing you for
instance to modify the document before it’s indexed by Solr or to add some
lines to the Solr log. It’s best demonstrated by an example.
<http://lucene.472066.n3.nabble.com/file/n4165380/Screen_Shot_2014-10-22_at_9.png>
--
View this message in context: http://lucene.472066.n3.nabble.com/StatelessScriptUpdateProcessorFactory-Access-to-Solr-Core-schema-analyzer-etc-tp4165372p4165380.html
Sent from the Solr - User mailing list archive at Nabble.com.