Johannes Baiter created SOLR-14931:
--------------------------------------
Summary: Macros in appends/invariants parameters not getting
expanded in Solrcloud
Key: SOLR-14931
URL: https://issues.apache.org/jira/browse/SOLR-14931
Project: Solr
Issue Type: Bug
Security Level: Public (Default Security Level. Issues are Public)
Components: SolrCloud
Affects Versions: 8.6.3, 7.6
Reporter: Johannes Baiter
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:
{code:xml}
<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>
{code}
When querying the handler with `?my_term=foobar&echoParams=all`, something like
this is the result:
{code:json}
{
"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
}
}
{code}
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
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]