You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Wei <we...@gmail.com> on 2023/05/25 17:03:52 UTC

Question on solr filter syntax

Send on behalf of my colleague as his email seems not showing up in the
list.

Hi Team,


I was reading about special filter syntax in Solr documentation -

https://solr.apache.org/guide/8_3/the-standard-query-parser.html#differences-between-lucenes-classic-query-parser-and-solrs-standard-query-parser


Support for a special filter(…) syntax to indicate that some query
clauses should be cached in the filter cache (as a constant score
boolean query). This allows sub-queries to be cached and re-used in
other queries. For example inStock:true will be cached and re-used in
all three of the queries below:

q=features:songs OR filter(inStock:true)


My question is how do I disable cache for part of OR filter query and
enable for part of OR filter query?


For e.g. - Current FQ -

fq: planName:all_features OR zipCode:1234 (in this case entire FQ is cached)


I don't want to cache the entire FQ given it's very unique , but I
want to cache the first part (plan_name:all_features) to improve
performance . How do I achieve this?


My understanding is the following should work? Is this correct?

fq: {!cache=false}(filter(planName:all_features) OR zipCode:1234)


Will the above syntax result in planName:all_features to be cached in
Filter Cache? Otherwise how can I achieve this?


I am on Solr 8.4


Thanks,

Yash

Re: Question on solr filter syntax

Posted by Mikhail Khludnev <mk...@apache.org>.
Hello, Yash.
The syntax you come up with makes sense. It's important to don't prepend it
with space; probably bracket may be redundant; you can also resolve syntax
ambiguity with local params.
fq={!cache=false v="filter(planName:all_features) OR zipCode:1234"}
debugQuery=true shows how it's parsed.
Another esoteric options:
https://solr.apache.org/guide/solr/latest/query-guide/block-join-query-parser.html#all-parents-syntax
fq={!cache=false v=$refq}&refq=zipCode:1234 {!parent
which=planName:all_features}


On Thu, May 25, 2023 at 8:04 PM Wei <we...@gmail.com> wrote:

> Send on behalf of my colleague as his email seems not showing up in the
> list.
>
> Hi Team,
>
>
> I was reading about special filter syntax in Solr documentation -
>
>
> https://solr.apache.org/guide/8_3/the-standard-query-parser.html#differences-between-lucenes-classic-query-parser-and-solrs-standard-query-parser
>
>
> Support for a special filter(…) syntax to indicate that some query
> clauses should be cached in the filter cache (as a constant score
> boolean query). This allows sub-queries to be cached and re-used in
> other queries. For example inStock:true will be cached and re-used in
> all three of the queries below:
>
> q=features:songs OR filter(inStock:true)
>
>
> My question is how do I disable cache for part of OR filter query and
> enable for part of OR filter query?
>
>
> For e.g. - Current FQ -
>
> fq: planName:all_features OR zipCode:1234 (in this case entire FQ is
> cached)
>
>
> I don't want to cache the entire FQ given it's very unique , but I
> want to cache the first part (plan_name:all_features) to improve
> performance . How do I achieve this?
>
>
> My understanding is the following should work? Is this correct?
>
> fq: {!cache=false}(filter(planName:all_features) OR zipCode:1234)
>
>
> Will the above syntax result in planName:all_features to be cached in
> Filter Cache? Otherwise how can I achieve this?
>
>
> I am on Solr 8.4
>
>
> Thanks,
>
> Yash
>


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