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 Alex Sylka <sy...@gmail.com> on 2015/03/27 17:22:38 UTC

Can SOLR custom analyzer access another field's value?

I am trying to write a custom analyzer , whose execution is determined by
the value of another field within the document.

For example if the locale field in the document has 'de' as the value, then
the analizer would use the German set of tokenizers/filters to process the
value of a field.

My question is : how can a custom analyzer access the value of another
field (in this case locale field) within a document, while analyzing the
value of a specific field?

There is a solution where we can prepend the locale value to the field's
value like de|fieldvalue then custom analyzer can extract the locale while
analyzing the field value. This seems a dirty solution. Is there any better
solution ?

Re: Can SOLR custom analyzer access another field's value?

Posted by Erick Erickson <er...@gmail.com>.
I think you're really writing a custom update processor that creates its own
analysis chain to do what you want. Likely this would be somewhat expensive
unless you could batch together user's documents so you'd only have to fetch
the stopwords once.

Then you'd have to do something equivalent at query time, assuming you allowed
query-time synonyms too.

Doing this per-user sounds like an ambitions project, I'd really ask
if it's worth
the effort? If you took the approach of having one collection per
user, it would all
"just work", but depending on how many users you have it could get difficult.

Best,
Erick

On Sat, Mar 28, 2015 at 4:14 PM, sylkaalex <sy...@gmail.com> wrote:
> My main goal creating custom stop word filter which will connect to my db and
> get stopwords list which will be different for each user. This filter will
> be attached to deal_title field and during indexing my documents I need to
> know which user is owner of this document (I can get this info from user_id
> field) and use appropriate stop words list for this user.
>
> <field name="user_id" type="int" indexed="true" stored="true"
> required="true" multiValued="false" />
>  <field name="deal_title" type="text_general" indexed="true" stored="true"
> required="false" multiValued="false"/>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Can-SOLR-custom-analyzer-access-another-field-s-value-tp4195851p4196110.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Can SOLR custom analyzer access another field's value?

Posted by sylkaalex <sy...@gmail.com>.
My main goal creating custom stop word filter which will connect to my db and
get stopwords list which will be different for each user. This filter will
be attached to deal_title field and during indexing my documents I need to
know which user is owner of this document (I can get this info from user_id
field) and use appropriate stop words list for this user. 

<field name="user_id" type="int" indexed="true" stored="true"
required="true" multiValued="false" />
 <field name="deal_title" type="text_general" indexed="true" stored="true"
required="false" multiValued="false"/>



--
View this message in context: http://lucene.472066.n3.nabble.com/Can-SOLR-custom-analyzer-access-another-field-s-value-tp4195851p4196110.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Can SOLR custom analyzer access another field's value?

Posted by Jack Krupansky <ja...@gmail.com>.
You could pre-process the field values in an update processor. You can even
write a snippet in JavaScript. You could check one field and then redirect
a field to an alternate field which has a different analyzer.

What expectations do you have as to what analysis should occur at query
time?

-- Jack Krupansky

On Fri, Mar 27, 2015 at 12:22 PM, Alex Sylka <sy...@gmail.com> wrote:

> I am trying to write a custom analyzer , whose execution is determined by
> the value of another field within the document.
>
> For example if the locale field in the document has 'de' as the value, then
> the analizer would use the German set of tokenizers/filters to process the
> value of a field.
>
> My question is : how can a custom analyzer access the value of another
> field (in this case locale field) within a document, while analyzing the
> value of a specific field?
>
> There is a solution where we can prepend the locale value to the field's
> value like de|fieldvalue then custom analyzer can extract the locale while
> analyzing the field value. This seems a dirty solution. Is there any better
> solution ?
>