lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Search using filter query on multivalued fields
Date Fri, 03 May 2019 16:01:34 GMT
There is no way to do this with the setup you describe. That is, there’s no way to say “only
use the third element of a multiValued field”.

What I’d do is index (perhaps in a separate field) with payloads, so you have input like
SALT|20, then use some of the payload functionality to make this happen. See: https://lucidworks.com/2017/09/14/solr-payloads/

There are some other strategies that are simpler, one could index (again, perhaps in a separate
field) SALT_20. Then you can form filter queries like “fq=ingredient:[SALT_20 TO *]. That’s
not very flexible and you have to normalize (i.e. 1% couldn’t be SALT_1), so “it depends”.

The point is that you have to index cleverly to do what you want.

Best,
Erick

> On May 3, 2019, at 6:26 AM, Srinivas Kashyap <srinivas@bamboorose.com> wrote:
> 
> Hi,
> 
> I have indexed data as shown below using DIH:
> 
> "INGREDIENT_NAME": [
>          "EGG",
>          "CANOLA OIL",
>          "SALT"
>        ],
> "INGREDIENT_NO": [
>          "550",
>          "297",
>          "314"
>        ],
> "COMPOSITION PERCENTAGE": [
>          20,
>          60,
>          40
>        ],
> 
> Similar to this, many other records are also indexed. These are multi-valued fields.
> 
> I have a requirement to search all the records which has ingredient name salt and it's
composition percentage is more than 20.
> 
> How do I write a filter query for this?
> 
> P.S: I should only fetch records, whose Salt Composition percentage is more than 20 and
not other percentages.
> 
> Thanks and Regards,
> Srinivas Kashyap
> ________________________________
> DISCLAIMER:
> E-mails and attachments from Bamboo Rose, LLC are confidential.
> If you are not the intended recipient, please notify the sender immediately by replying
to the e-mail, and then delete it without making copies or using it in any way.
> No representation is made that this email or any attachments are free of viruses. Virus
scanning is recommended and is the responsibility of the recipient.


Mime
View raw message