how to add multiple value for a filter query in Solrj

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

how to add multiple value for a filter query in Solrj

Szűcs Roland
Hi All,

I use Solr 8.4.1 and the latest solrj client.
There is a field let's which can have 3 different values. If I use the
admin UI, I write to the fq the following: filterName:"value1"
filterName:"value2" and it is working as expected.
If I use solrJ SolrQuery.addFilterQuery method and call it twice like:
addFilterQuery(filterName+":\""+value1+"\"");
addFilterQuery(filterName+":\""+value2+"\"");
I got no any document back.

Can somebody help me what syntax is appropriate with solrj to add filter
queries one by one if there is one filter field but multiple values?

Thanks,

Roland
Reply | Threaded
Open this post in threaded view
|

RE: how to add multiple value for a filter query in Solrj

Raboah, Avi
You can do something like that if we are talking on the same filter query name.

addFilterQuery(String.format("%s:(%s %s)", filterName, value1, value2));


-----Original Message-----
From: Szűcs Roland <[hidden email]>
Sent: Tuesday, March 24, 2020 11:35 AM
To: [hidden email]
Subject: how to add multiple value for a filter query in Solrj

Hi All,

I use Solr 8.4.1 and the latest solrj client.
There is a field let's which can have 3 different values. If I use the admin UI, I write to the fq the following: filterName:"value1"
filterName:"value2" and it is working as expected.
If I use solrJ SolrQuery.addFilterQuery method and call it twice like:
addFilterQuery(filterName+":\""+value1+"\"");
addFilterQuery(filterName+":\""+value2+"\"");
I got no any document back.

Can somebody help me what syntax is appropriate with solrj to add filter queries one by one if there is one filter field but multiple values?

Thanks,

Roland


This electronic message may contain proprietary and confidential information of Verint Systems Inc., its affiliates and/or subsidiaries. The information is intended to be for the use of the individual(s) or entity(ies) named above. If you are not the intended recipient (or authorized to receive this e-mail for the intended recipient), you may not use, copy, disclose or distribute to anyone this message or any information contained in this message. If you have received this electronic message in error, please notify us by replying to this e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: how to add multiple value for a filter query in Solrj

Szűcs Roland
Thanks Avi, it worked.

Raboah, Avi <[hidden email]> ezt írta (időpont: 2020. márc. 24., K,
11:08):

> You can do something like that if we are talking on the same filter query
> name.
>
> addFilterQuery(String.format("%s:(%s %s)", filterName, value1, value2));
>
>
> -----Original Message-----
> From: Szűcs Roland <[hidden email]>
> Sent: Tuesday, March 24, 2020 11:35 AM
> To: [hidden email]
> Subject: how to add multiple value for a filter query in Solrj
>
> Hi All,
>
> I use Solr 8.4.1 and the latest solrj client.
> There is a field let's which can have 3 different values. If I use the
> admin UI, I write to the fq the following: filterName:"value1"
> filterName:"value2" and it is working as expected.
> If I use solrJ SolrQuery.addFilterQuery method and call it twice like:
> addFilterQuery(filterName+":\""+value1+"\"");
> addFilterQuery(filterName+":\""+value2+"\"");
> I got no any document back.
>
> Can somebody help me what syntax is appropriate with solrj to add filter
> queries one by one if there is one filter field but multiple values?
>
> Thanks,
>
> Roland
>
>
> This electronic message may contain proprietary and confidential
> information of Verint Systems Inc., its affiliates and/or subsidiaries. The
> information is intended to be for the use of the individual(s) or
> entity(ies) named above. If you are not the intended recipient (or
> authorized to receive this e-mail for the intended recipient), you may not
> use, copy, disclose or distribute to anyone this message or any information
> contained in this message. If you have received this electronic message in
> error, please notify us by replying to this e-mail.
>
Reply | Threaded
Open this post in threaded view
|

Re: how to add multiple value for a filter query in Solrj

Erick Erickson
In reply to this post by Szűcs Roland
Your original formation of the filter query has two problems:

1> you included a “+” in the value. My guess is that you misinterpreted the
     URL you got back from the browser in the admin UI where a “+” is a
     URL-encoded space. You’ll also see a bunch of %XX in the URL which are
     other encodings.

2> you include double quotes, which can change things to be phrase queries.

Looking at the debug version would have helped you pinpoint these.


> On Mar 24, 2020, at 5:34 AM, Szűcs Roland <[hidden email]> wrote:
>
> Hi All,
>
> I use Solr 8.4.1 and the latest solrj client.
> There is a field let's which can have 3 different values. If I use the
> admin UI, I write to the fq the following: filterName:"value1"
> filterName:"value2" and it is working as expected.
> If I use solrJ SolrQuery.addFilterQuery method and call it twice like:
> addFilterQuery(filterName+":\""+value1+"\"");
> addFilterQuery(filterName+":\""+value2+"\"");
> I got no any document back.
>
> Can somebody help me what syntax is appropriate with solrj to add filter
> queries one by one if there is one filter field but multiple values?
>
> Thanks,
>
> Roland