Function Query with multi-value field

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

Function Query with multi-value field

weiwang19
Hi,

I have a question regarding function query that operates on multi-value
fields.  For the following field:

<field name=rgbcolor type="string" indexed="true" stored="true"
multivalued="true"/>

 Each value is a hex string representation of RGB value.  for example there
are 3 values indexed

#FF00FF    - C1
#EE82EE   - C2
#DA70D6   - C3

How would I write a function query that operates on all values of the
field?  Given color S in query, how to calculate the similarities between S
and C1/C2/C3 and find which one is the closest?
I checked https://lucene.apache.org/solr/guide/6_6/function-queries.html but
didn't see an example.

Thanks,
Wei
Reply | Threaded
Open this post in threaded view
|

Re: Function Query with multi-value field

weiwang19
Any suggestion?

On Thu, Jul 11, 2019 at 3:03 PM Wei <[hidden email]> wrote:

> Hi,
>
> I have a question regarding function query that operates on multi-value
> fields.  For the following field:
>
> <field name=rgbcolor type="string" indexed="true" stored="true"
> multivalued="true"/>
>
>  Each value is a hex string representation of RGB value.  for example
> there are 3 values indexed
>
> #FF00FF    - C1
> #EE82EE   - C2
> #DA70D6   - C3
>
> How would I write a function query that operates on all values of the
> field?  Given color S in query, how to calculate the similarities between
> S and C1/C2/C3 and find which one is the closest?
> I checked https://lucene.apache.org/solr/guide/6_6/function-queries.html but
> didn't see an example.
>
> Thanks,
> Wei
>
Reply | Threaded
Open this post in threaded view
|

Re: Function Query with multi-value field

Emir Arnautović
Hi Wei,
I see two options:
1. create custom distance function for colors
2. split each color component to a separate numeric fields and try calculate distance function using standard set of functions. (I think that Solr does not support 3d points).

HTH,
Emir
--
Monitoring - Log Management - Alerting - Anomaly Detection
Solr & Elasticsearch Consulting Support Training - http://sematext.com/



> On 14 Jul 2019, at 00:47, Wei <[hidden email]> wrote:
>
> Any suggestion?
>
> On Thu, Jul 11, 2019 at 3:03 PM Wei <[hidden email]> wrote:
>
>> Hi,
>>
>> I have a question regarding function query that operates on multi-value
>> fields.  For the following field:
>>
>> <field name=rgbcolor type="string" indexed="true" stored="true"
>> multivalued="true"/>
>>
>> Each value is a hex string representation of RGB value.  for example
>> there are 3 values indexed
>>
>> #FF00FF    - C1
>> #EE82EE   - C2
>> #DA70D6   - C3
>>
>> How would I write a function query that operates on all values of the
>> field?  Given color S in query, how to calculate the similarities between
>> S and C1/C2/C3 and find which one is the closest?
>> I checked https://lucene.apache.org/solr/guide/6_6/function-queries.html but
>> didn't see an example.
>>
>> Thanks,
>> Wei
>>