You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Steven White <sw...@gmail.com> on 2023/04/14 12:15:22 UTC

Avoid the need to use OR operator

Hi everyone,

I have the following very long query that I need to send to Solr:

> search-text some-other-limits UNIQUE_MODELS:(19 OR 20 OR 9532 OR ...)

See how I'm narrowing my query to a list of values limited to the field
UNIQUE_MODELS ?

The number of items that can be passed to UNIQUE_MODELS can be very large
as such I'm hitting the URL character limit.

This is legacy code and it is not feasible to change the HTTP from GET to
POST.  Furthermore, the default boolean operator is AND and that too I
cannot change it to OR.

Given the above, I was thinking if there is a way to shorten the request
I'm sending to Solr by eliminating the ORs inside UNIQUE_MODELS.  That is,
build the Solr request such as telling Solr to use OR for items listed in
UNIQUE_MODELS, without repeating OR, but keep using the default AND for
everything else that could be part of this query.

I.e.: can I say: UNIQUE_MODELS:(<user-OR> 19 20 9532 ...)

Is there a Solr syntax to do this?

Thanks in advance.

Steven

Re: Avoid the need to use OR operator

Posted by Mikhail Khludnev <mk...@apache.org>.
Hi, Steven.
What about
q=search-text some-other-limits {!terms f=UNIQUE_MODELS
v=$um}&um=19,20,9532,..
Although it's quite limited without POST. Also, note there are many traps
in this syntax, check debugQuery output thoroughly.

see
https://solr.apache.org/guide/7_3/other-parsers.html#terms-query-parser
https://solr.apache.org/guide/7_3/local-parameters-in-queries.html#parameter-dereferencing


On Fri, Apr 14, 2023 at 3:18 PM Steven White <sw...@gmail.com> wrote:

> Hi everyone,
>
> I have the following very long query that I need to send to Solr:
>
> > search-text some-other-limits UNIQUE_MODELS:(19 OR 20 OR 9532 OR ...)
>
> See how I'm narrowing my query to a list of values limited to the field
> UNIQUE_MODELS ?
>
> The number of items that can be passed to UNIQUE_MODELS can be very large
> as such I'm hitting the URL character limit.
>
> This is legacy code and it is not feasible to change the HTTP from GET to
> POST.  Furthermore, the default boolean operator is AND and that too I
> cannot change it to OR.
>
> Given the above, I was thinking if there is a way to shorten the request
> I'm sending to Solr by eliminating the ORs inside UNIQUE_MODELS.  That is,
> build the Solr request such as telling Solr to use OR for items listed in
> UNIQUE_MODELS, without repeating OR, but keep using the default AND for
> everything else that could be part of this query.
>
> I.e.: can I say: UNIQUE_MODELS:(<user-OR> 19 20 9532 ...)
>
> Is there a Solr syntax to do this?
>
> Thanks in advance.
>
> Steven
>


-- 
Sincerely yours
Mikhail Khludnev
https://t.me/MUST_SEARCH
A caveat: Cyrillic!

Re: Avoid the need to use OR operator

Posted by Vivaldi <uy...@vivaldi.net.INVALID>.
Did you try using q.op=OR as request parameter? It should override the default boolean operator. 


> On 14 Apr 2023, at 15:15, Steven White <sw...@gmail.com> wrote:
> 
> Hi everyone,
> 
> I have the following very long query that I need to send to Solr:
> 
>> search-text some-other-limits UNIQUE_MODELS:(19 OR 20 OR 9532 OR ...)
> 
> See how I'm narrowing my query to a list of values limited to the field
> UNIQUE_MODELS ?
> 
> The number of items that can be passed to UNIQUE_MODELS can be very large
> as such I'm hitting the URL character limit.
> 
> This is legacy code and it is not feasible to change the HTTP from GET to
> POST.  Furthermore, the default boolean operator is AND and that too I
> cannot change it to OR.
> 
> Given the above, I was thinking if there is a way to shorten the request
> I'm sending to Solr by eliminating the ORs inside UNIQUE_MODELS.  That is,
> build the Solr request such as telling Solr to use OR for items listed in
> UNIQUE_MODELS, without repeating OR, but keep using the default AND for
> everything else that could be part of this query.
> 
> I.e.: can I say: UNIQUE_MODELS:(<user-OR> 19 20 9532 ...)
> 
> Is there a Solr syntax to do this?
> 
> Thanks in advance.
> 
> Steven