[
https://issues.apache.org/jira/browse/SOLR-17796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18125302#comment-18125302
]
David Smiley commented on SOLR-17796:
-------------------------------------
Sharing a nice analysis by Opus that I agree with. I'm sympathetic to the user
experience sucking in this situation and I am busy filing an issue that would
end up fixing this.
🤖 Note the title is backwards: per the description, it's {{q.op=AND}} that
fails and {{OR}} that works.
The problem is where the tag is placed. In
{noformat}
fq={!tag=collapse_tag}{!collapse field=someid}
{noformat}
the leading local-params names no query parser, so the whole thing is parsed by
the {{lucene}} parser and the collapse becomes a _nested_ clause of it. With
{{q.op=OR}} the parser happens to unwrap a lone optional clause, so Solr still
sees the collapse query directly and treats it as a post filter. With
{{q.op=AND}} the lone clause is required and stays wrapped in a BooleanQuery;
Solr no longer recognizes it as a post filter, tries to execute it as an
ordinary filter, and you get the "does not implement createWeight" exception.
Put the tag on the collapse parser itself, which works regardless of
{{{}q.op{}}}:
{noformat}
fq={!collapse tag=collapse_tag field=someid}
{noformat}
and then exclude it on the facet as usual, e.g. {{facet.field=
{!ex=collapse_tag}
doc_type}}
That said, behavior that differs by {{q.op}} here is a trap; the lucene parser
could unwrap a single required clause the same way it does a single optional
one.
🤖 Generated with [Claude Code|https://claude.com/claude-code]
> Exclusion tag on fq collapse does not work with q.op OR
> -------------------------------------------------------
>
> Key: SOLR-17796
> URL: https://issues.apache.org/jira/browse/SOLR-17796
> Project: Solr
> Issue Type: Bug
> Components: query, query parsers
> Affects Versions: 9.8.1
> Reporter: Morten Staffeldt
> Priority: Major
> Labels: lucene, query-parser, solr
>
> Im using tag and collapse on a filterQuery.
> The tag is to be used to exclude the collapse on the facets, so i avoid the
> it collapsing on whatever item it collapses on.This all seems to work when
> using q.op OR.
> If i however change it to q.op AND i get the following exception -->
> {{}}
> {code:java}
> java.lang.UnsupportedOperationException: Query
> CollapsingPostFilter(field=workid, nullPolicy=ignore,
> GroupHeadSelector(selectorText=score, type=SCORE), size=100000) does not
> implement createWeight{code}
> Can be reproduced by
> {code:java}
> {code}
> {{#define col
> curl --request POST \
> --url http://localhost:8983/api/collections \
> --header 'Content-Type: application/json' \
> --data '\{
> "name": "bugtest",
> "numShards": 1,
> "replicationFactor": 1
> }'
> #create schema
> curl --request POST \
> --url http://localhost:8983/api/collections/bugtest/schema \
> --header 'Content-Type: application/json' \
> --data '\{
> "add-field": [
> {"name": "someid", "type": "string", "indexed":true, "required":true,
> "stored":true},
> \{"name": "doc_type", "type": "string", "multiValued":false,
> "indexed":true, "required":true, "stored":true}
> ]
> }'}}
> {code:java}
> {code}
> {{Works with q.op OR -->
> http://localhost:8983/solr/#/bugtest/query?q=*:*&q.op=OR&indent=true&fq=%7B!tag%3Dcollapse_tag%7D%7B!collapse%20field%3Dsomeid%7D&useParams=}}
> {code:java}
> {code}
> {{Does not work qith q.op AND -->
> http://localhost:8983/solr/#/bugtest/query?q=*:*&q.op=AND&indent=true&fq=%7B!tag%3Dcollapse_tag%7D%7B!collapse%20field%3Dsomeid%7D&useParams=}}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]