You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Matthew Castrigno <ca...@slhs.org> on 2022/12/09 17:22:33 UTC

Using the fq parameter to filter for a value that is multivalued field.

I am having trouble using the fq parameter to filter for a value that is in a muilt-valued field.

This works:
"myField":["apple"]

fq=myField:"apple"

document is returned


This does not work:
"myField":["apple, pear"]

fq=myField:"apple"

document is NOT returned

What do I need to do get fq to find a value in a multi-valued field?

Thank you!


----------------------------------------------------------------------
"This message is intended for the use of the person or entity to which it is addressed and may contain information that is confidential or privileged, the disclosure of which is governed by applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this information is strictly prohibited. If you have received this message by error, please notify us immediately and destroy the related message."

Re: Using the fq parameter to filter for a value that is multivalued field.

Posted by Dave <ha...@gmail.com>.
"apple, pear"

That looks like a string not a multi valued field to me. Maybe I’m wrong but you should have quotes around each element of the array 

> On Dec 9, 2022, at 12:23 PM, Matthew Castrigno <ca...@slhs.org> wrote:
> 
> "apple, pear"

Re: Using the fq parameter to filter for a value that is multivalued field.

Posted by Andy Lester <an...@petdance.com>.

> On Dec 9, 2022, at 11:22 AM, Matthew Castrigno <ca...@slhs.org> wrote:
> 
> "myField":["apple, pear"]


That's not multivalued.  That's a single value and the value is "apple, pear".

You need to pass multiple values to Solr for the field when you do your indexing.  Basically, you need to pass one myField:apple and another myField:pear to the indexer when you add records.

Andy

Re: Using the fq parameter to filter for a value that is multivalued field.

Posted by David Hastings <ha...@gmail.com>.
Of course.  Also, remember there are things to consider like if you want to
store/retrieve it as an absolute string including capitalization for a
facet/Drop down selection or only as a search field. lots of nuances.
-Dave

Re: Using the fq parameter to filter for a value that is multivalued field.

Posted by Matthew Castrigno <ca...@slhs.org>.
Thanks Dave. That seems to work.
________________________________
From: Dave <ha...@gmail.com>
Sent: Friday, December 9, 2022 11:19 AM
To: Matthew Castrigno <ca...@slhs.org>
Cc: users@solr.apache.org <us...@solr.apache.org>; andy@petdance.com <an...@petdance.com>
Subject: Re: Using the fq parameter to filter for a value that is multivalued field.

Try adding each value separately. Not joined in code, let solr do the multivalue work, On Dec 9, 2022, at 1: 11 PM, Matthew Castrigno <castrigm@ slhs. org> wrote:  Thank you for your comments that appears to be the root of the problem. 
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside the St. Luke's email system.

ZjQcmQRYFpfptBannerEnd
Try adding each value separately. Not joined in code, let solr do the multivalue work,

On Dec 9, 2022, at 1:11 PM, Matthew Castrigno <ca...@slhs.org> wrote:


Thank you for your comments that appears to be the root of the problem.

Fixing it raises another question.

The incorrect multivalued fields were being created with a script line:
doc.addField("facets_ss", contentObject.Page.Facets.join(","));

When I try to fix that with:
doc.addField("facets_ss", contentObject.Page.Facets.join('","'));
or
doc.addField("facets_ss", contentObject.Page.Facets.join("\",\""));

SOLR is adding escape characters that I do not want:
facets_ss":["Blogs\",\"Article"]

Instead of
facets_ss":["Blogs","Article"]

How do I get SOPLR to not add the \ ?

Thank you!



________________________________
From: Walter Underwood <wu...@wunderwood.org>
Sent: Friday, December 9, 2022 10:42 AM
To: users@solr.apache.org <us...@solr.apache.org>
Subject: Re: Using the fq parameter to filter for a value that is multivalued field.

If you want apple OR pear, use: myField: apple myField: pear If you want apple AND pear, use: +myField: apple +myField: pear wunder Walter Underwood wunder@ wunderwood. org https: //urldefense. com/v3/__http: //observer. wunderwood. org/__;!!FkC3_z_N!LRDNStCCNvSo41v6qHKPwTuNZI6crIfaKdZYFvi5GOnrHPe-Mydnv-DIN9QR0Ljh37Du8EPZPnVx0u66$
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside the St. Luke's email system.

ZjQcmQRYFpfptBannerEnd

If you want apple OR pear, use:

myField:apple myField:pear

If you want apple AND pear, use:

+myField:apple +myField:pear

wunder
Walter Underwood
wunder@wunderwood.org
https://urldefense.com/v3/__http://observer.wunderwood.org/__;!!FkC3_z_N!LRDNStCCNvSo41v6qHKPwTuNZI6crIfaKdZYFvi5GOnrHPe-Mydnv-DIN9QR0Ljh37Du8EPZPnVx0u66$  (my blog)

> On Dec 9, 2022, at 9:22 AM, Matthew Castrigno <ca...@slhs.org> wrote:
>
> I am having trouble using the fq parameter to filter for a value that is in a muilt-valued field.
>
> This works:
> "myField":["apple"]
>
> fq=myField:"apple"
>
> document is returned
>
>
> This does not work:
> "myField":["apple, pear"]
>
> fq=myField:"apple"
>
> document is NOT returned
>
> What do I need to do get fq to find a value in a multi-valued field?
>
> Thank you!
>
>
> ----------------------------------------------------------------------
> "This message is intended for the use of the person or entity to which it is addressed and may contain information that is confidential or privileged, the disclosure of which is governed by applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this information is strictly prohibited. If you have received this message by error, please notify us immediately and destroy the related message."



________________________________
"This message is intended for the use of the person or entity to which it is addressed and may contain information that is confidential or privileged, the disclosure of which is governed by applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this information is strictly prohibited. If you have received this message by error, please notify us immediately and destroy the related message."

----------------------------------------------------------------------
"This message is intended for the use of the person or entity to which it is addressed and may contain information that is confidential or privileged, the disclosure of which is governed by applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this information is strictly prohibited. If you have received this message by error, please notify us immediately and destroy the related message."

Re: Using the fq parameter to filter for a value that is multivalued field.

Posted by Dave <ha...@gmail.com>.
Try adding each value separately. Not joined in code, let solr do the multivalue work, 

> On Dec 9, 2022, at 1:11 PM, Matthew Castrigno <ca...@slhs.org> wrote:
> 
> 
> Thank you for your comments that appears to be the root of the problem.
> 
> Fixing it raises another question.
> 
> The incorrect multivalued fields were being created with a script line:
> doc.addField("facets_ss", contentObject.Page.Facets.join(","));
> 
> When I try to fix that with:
> doc.addField("facets_ss", contentObject.Page.Facets.join('","'));
> or
> doc.addField("facets_ss", contentObject.Page.Facets.join("\",\""));
> 
> SOLR is adding escape characters that I do not want:
> facets_ss":["Blogs\",\"Article"]
> 
> Instead of 
> facets_ss":["Blogs","Article"]
> 
> How do I get SOPLR to not add the \ ?
> 
> Thank you!
> 
> 
> 
> From: Walter Underwood <wu...@wunderwood.org>
> Sent: Friday, December 9, 2022 10:42 AM
> To: users@solr.apache.org <us...@solr.apache.org>
> Subject: Re: Using the fq parameter to filter for a value that is multivalued field.
>  
> This Message Is From an External Sender
> This message came from outside the St. Luke's email system.
> If you want apple OR pear, use:
> 
> myField:apple myField:pear
> 
> If you want apple AND pear, use:
> 
> +myField:apple +myField:pear
> 
> wunder
> Walter Underwood
> wunder@wunderwood.org
> https://urldefense.com/v3/__http://observer.wunderwood.org/__;!!FkC3_z_N!LRDNStCCNvSo41v6qHKPwTuNZI6crIfaKdZYFvi5GOnrHPe-Mydnv-DIN9QR0Ljh37Du8EPZPnVx0u66$  (my blog)
> 
> > On Dec 9, 2022, at 9:22 AM, Matthew Castrigno <ca...@slhs.org> wrote:
> > 
> > I am having trouble using the fq parameter to filter for a value that is in a muilt-valued field.
> > 
> > This works:
> > "myField":["apple"]
> > 
> > fq=myField:"apple"
> > 
> > document is returned
> > 
> > 
> > This does not work:
> > "myField":["apple, pear"]
> > 
> > fq=myField:"apple"
> > 
> > document is NOT returned
> > 
> > What do I need to do get fq to find a value in a multi-valued field?
> > 
> > Thank you!
> > 
> > 
> > ----------------------------------------------------------------------
> > "This message is intended for the use of the person or entity to which it is addressed and may contain information that is confidential or privileged, the disclosure of which is governed by applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this information is strictly prohibited. If you have received this message by error, please notify us immediately and destroy the related message."
> 
> "This message is intended for the use of the person or entity to which it is addressed and may contain information that is confidential or privileged, the disclosure of which is governed by applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this information is strictly prohibited. If you have received this message by error, please notify us immediately and destroy the related message."

Re: Using the fq parameter to filter for a value that is multivalued field.

Posted by Matthew Castrigno <ca...@slhs.org>.
Thank you for your comments that appears to be the root of the problem.

Fixing it raises another question.

The incorrect multivalued fields were being created with a script line:
doc.addField("facets_ss", contentObject.Page.Facets.join(","));

When I try to fix that with:
doc.addField("facets_ss", contentObject.Page.Facets.join('","'));
or
doc.addField("facets_ss", contentObject.Page.Facets.join("\",\""));

SOLR is adding escape characters that I do not want:
facets_ss":["Blogs\",\"Article"]

Instead of
facets_ss":["Blogs","Article"]

How do I get SOPLR to not add the \ ?

Thank you!



________________________________
From: Walter Underwood <wu...@wunderwood.org>
Sent: Friday, December 9, 2022 10:42 AM
To: users@solr.apache.org <us...@solr.apache.org>
Subject: Re: Using the fq parameter to filter for a value that is multivalued field.

If you want apple OR pear, use: myField: apple myField: pear If you want apple AND pear, use: +myField: apple +myField: pear wunder Walter Underwood wunder@ wunderwood. org https: //urldefense. com/v3/__http: //observer. wunderwood. org/__;!!FkC3_z_N!LRDNStCCNvSo41v6qHKPwTuNZI6crIfaKdZYFvi5GOnrHPe-Mydnv-DIN9QR0Ljh37Du8EPZPnVx0u66$
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside the St. Luke's email system.

ZjQcmQRYFpfptBannerEnd

If you want apple OR pear, use:

myField:apple myField:pear

If you want apple AND pear, use:

+myField:apple +myField:pear

wunder
Walter Underwood
wunder@wunderwood.org
https://urldefense.com/v3/__http://observer.wunderwood.org/__;!!FkC3_z_N!LRDNStCCNvSo41v6qHKPwTuNZI6crIfaKdZYFvi5GOnrHPe-Mydnv-DIN9QR0Ljh37Du8EPZPnVx0u66$  (my blog)

> On Dec 9, 2022, at 9:22 AM, Matthew Castrigno <ca...@slhs.org> wrote:
>
> I am having trouble using the fq parameter to filter for a value that is in a muilt-valued field.
>
> This works:
> "myField":["apple"]
>
> fq=myField:"apple"
>
> document is returned
>
>
> This does not work:
> "myField":["apple, pear"]
>
> fq=myField:"apple"
>
> document is NOT returned
>
> What do I need to do get fq to find a value in a multi-valued field?
>
> Thank you!
>
>
> ----------------------------------------------------------------------
> "This message is intended for the use of the person or entity to which it is addressed and may contain information that is confidential or privileged, the disclosure of which is governed by applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this information is strictly prohibited. If you have received this message by error, please notify us immediately and destroy the related message."



----------------------------------------------------------------------
"This message is intended for the use of the person or entity to which it is addressed and may contain information that is confidential or privileged, the disclosure of which is governed by applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this information is strictly prohibited. If you have received this message by error, please notify us immediately and destroy the related message."

Re: Using the fq parameter to filter for a value that is multivalued field.

Posted by Walter Underwood <wu...@wunderwood.org>.
If you want apple OR pear, use:

myField:apple myField:pear

If you want apple AND pear, use:

+myField:apple +myField:pear

wunder
Walter Underwood
wunder@wunderwood.org
http://observer.wunderwood.org/  (my blog)

> On Dec 9, 2022, at 9:22 AM, Matthew Castrigno <ca...@slhs.org> wrote:
> 
> I am having trouble using the fq parameter to filter for a value that is in a muilt-valued field.
> 
> This works:
> "myField":["apple"]
> 
> fq=myField:"apple"
> 
> document is returned
> 
> 
> This does not work:
> "myField":["apple, pear"]
> 
> fq=myField:"apple"
> 
> document is NOT returned
> 
> What do I need to do get fq to find a value in a multi-valued field?
> 
> Thank you!
> 
> 
> ----------------------------------------------------------------------
> "This message is intended for the use of the person or entity to which it is addressed and may contain information that is confidential or privileged, the disclosure of which is governed by applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this information is strictly prohibited. If you have received this message by error, please notify us immediately and destroy the related message."