Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
7.6, 8.6.3
-
None
-
None
Description
Macros in a request handler's appends or invariants parameter sets are not getting expanded when running in a SolrCloud setup.
In my case, I have a handler like the following:
<requestHandler name="/myhandler" class="solr.SearchHandler"> <lst name="defaults"> <str name="q">some_field:"$${my_term}"</str> <str name="fl">term_defaults:'$${my_term},freq_defaults:docfreq(some_field, '$${my_term}')</str> </lst> <lst name="appends"> <str name="fl">term_appends:'$${my_term}',freq_appends:docfreq(some_field, '$${my_term}')</str> </lst> </requestHandler>
When querying the handler with `?my_term=foobar&echoParams=all`, something like this is the result:
{ "response": { "docs": [ { "term_defaults": "foobar", "term_appends": "${my_term}", "freq_appends": 0, "freq_defaults": 1 } ], "maxScore": 13.244947, "numFound": 1, "start": 0 }, "responseHeader": { "QTime": 262091, "params": { "echoParams": "all", "fl": [ "term_defaults:'foobar',freq_defaults:docfreq(some_field, 'foobar')", "term_appends:'foobar',freq_appends:docfreq(some_field, 'foobar')" ], "my_term": "foobar", "q": "some_field:\"foobar\"", "rows": "1" }, "status": 0, "zkConnected": true } }
As you can see, the macro in the appends fl parameter gets expanded in the responseHeader.params.fl field, but not in the actual document.
I believe the reason for this is the following:
- Setting of defaults/invariants/appends happens once before the request gets sent to the shards
- Here, macro expansion happens, i.e. the shards get the fully expanded parameters
- On the shards, once again, defaults/invariants/appends are set (https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java#L209)
- However, this time macros are not expanded (https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java#L151-L161)
- For defaults parameters, this doesn't break anything, since the (expanded) parameter from the request takes precedence over the server-supplied value.
- However, for appends, both the expanded and the unexpanded version are now set, while for invariants the expanded value is removed from the params
I think the easy/obvious fix for this would be not to set defaults/invariants/appends parameters twice, i.e. disable it when isShard=true, just like macro expansion, but I don't have the full picture if that might not break something else.
Here's the Twitter thread where I rubber-ducked through this issue: https://twitter.com/jbaiter_/status/1316023733576843272
Attachments
Issue Links
- relates to
-
SOLR-10059 In SolrCloud, every fq added via <lst name="appends"> is computed twice.
- Open