Accessing multiValued field from within custom function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing multiValued field from within custom function

Dariusz Wojtas
Hi,

I am using SOLR 7.5 in the cloud mode.
I want to create a custom function similar to 'strdist' that works on
multivalued fields (multiValued=true) and finds the highest matching score.
Yes, I know the potential performance issues, but in my usecase this would
bring a huge benefit.

There is not much information on how to work with multiValued fields, but I
have found a piece of code that might be useful. It's how SOLR standard
functions are registered:
https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java

The interesting part for me starts in line 424, when the 'field' function
is registered.
It optionally accepts a multivalue field for min/max calculation.
If the 2nd argument is 'min' or 'max' it tries to resolve the field as
SchemaField.
  SchemaField f = fp.getReq().getSchema().getField(fieldName);

Now the questions are:
1. Is this the path I should follow? If not - are there any other ways?
2. How to retrieve all the actual *String *or *Text *values from a
multivalue field, not just a single value? Some kind of a table or set of
values. How?
3. Does cloud mode change anything here? In my case the whole index is on a
single machine, but there are several replicas.

Best regards,
Dariusz Wojtas
Reply | Threaded
Open this post in threaded view
|

Re: Accessing multiValued field from within custom function

Dariusz Wojtas
Hi,

Any hints on this topic?
How to access String / Text values from a multiValued field inside custom
function?

Best regards,
Dariusz Wojtas

On Thu, Jan 3, 2019 at 6:18 PM Dariusz Wojtas <[hidden email]> wrote:

> Hi,
>
> I am using SOLR 7.5 in the cloud mode.
> I want to create a custom function similar to 'strdist' that works on
> multivalued fields (multiValued=true) and finds the highest matching score.
> Yes, I know the potential performance issues, but in my usecase this would
> bring a huge benefit.
>
> There is not much information on how to work with multiValued fields, but
> I have found a piece of code that might be useful. It's how SOLR standard
> functions are registered:
>
> https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
>
> The interesting part for me starts in line 424, when the 'field' function
> is registered.
> It optionally accepts a multivalue field for min/max calculation.
> If the 2nd argument is 'min' or 'max' it tries to resolve the field as
> SchemaField.
>   SchemaField f = fp.getReq().getSchema().getField(fieldName);
>
> Now the questions are:
> 1. Is this the path I should follow? If not - are there any other ways?
> 2. How to retrieve all the actual *String *or *Text *values from a
> multivalue field, not just a single value? Some kind of a table or set of
> values. How?
> 3. Does cloud mode change anything here? In my case the whole index is on
> a single machine, but there are several replicas.
>
> Best regards,
> Dariusz Wojtas
>
>