You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Szűcs Roland <sz...@bookandwalk.hu> on 2020/03/24 09:34:56 UTC
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
Re: how to add multiple value for a filter query in Solrj
Posted by Szűcs Roland <sz...@bookandwalk.hu>.
Thanks Avi, it worked.
Raboah, Avi <Av...@verint.com> 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 <sz...@bookandwalk.hu>
> Sent: Tuesday, March 24, 2020 11:35 AM
> To: solr-user@lucene.apache.org
> 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.
>
RE: how to add multiple value for a filter query in Solrj
Posted by "Raboah, Avi" <Av...@verint.com>.
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 <sz...@bookandwalk.hu>
Sent: Tuesday, March 24, 2020 11:35 AM
To: solr-user@lucene.apache.org
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.
Re: how to add multiple value for a filter query in Solrj
Posted by Erick Erickson <er...@gmail.com>.
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 <sz...@bookandwalk.hu> 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