See how, in the following requests, {{f_type=OBJECT_PROPERTY}} is dropped / replaced with {{{}f_type=DOCUMENT{}}}.
{{{color:#18b218}curl{color}{color:#000000} --head {color}{color:#b26818}'http://localhost:8080/xwiki/bin/view/Main/Search?text=Hello&f_type=OBJECT_PROPERTY&f_locale=en&f_locale=' {color}HTTP/1.1 302 Found}} {{Location: http://localhost:8080/xwiki/bin/view/Main/Search?text=Hello&f_type=DOCUMENT&f_locale=en&f_locale=&r=1}}
{{{color:#18b218}curl{color}{color:#000000} --head {color}{color:#b26818}'http://localhost:8091/xwiki/bin/view/Main/Search?text=Hello&f_type=DOCUMENT&f_type=OBJECT_PROPERTY&f_locale=en&f_locale=' {color}HTTP/1.1 302 Found}} {{Location: http://localhost:8080/xwiki/bin/view/Main/Search?text=Hello&f_type=DOCUMENT&f_locale=en&f_locale=&r=1}}
After investigation, this seems to happen [in macro handleSolrSearchRequest, in xwiki-platform/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-ui/src/main/resources/Main/SolrSearchMacros.xml, when it calls {{extendQueryString}}|https://github.com/xwiki/xwiki-platform/blob/7e050625527d25bfe887881d8579159a77926a1c/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-ui/src/main/resources/Main/SolrSearchMacros.xml#L973].
[{{extendQueryString}}|https://github.com/xwiki/xwiki-platform/blob/7e050625527d25bfe887881d8579159a77926a1c/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-ui/src/main/resources/Main/SolrSearchMacros.xml#L150] doesn't extend, but overwrites, because its {{extraParameters}} is a {{Map<String, String>}} while {{$request.getParameterMap()}} is a {{Map<String, String[]>}} (or something equivalent), so its second {{addAll}} call overwrites everything.
The following "fixed" version of {{extendQueryString}} behaves as I would expect, where parameters in {{$extraParameters}} are added to the existing parameters, if not already there, keeping the order (though I'm not sure this last part matters much in the case of Solr. (By the way, {{extendQueryString}} seems like a useful function to expose more generally to velocity code in XWiki).
I don't know if this "fixed" version has unwanted side effects though. {code:java} #macro (extendQueryString $url $extraParameters) #set ($parameters = {}) #set ($discard = $parameters.putAll($request.getParameterMap())) #foreach ($entry in $extraParameters.entrySet()) #set ($currentValues = $parameters[$entry.key]) #if ($objecttool.isNull($currentValues)) #set ($extendedValue = $entry.value) #else #set ($extendedValue = $collectiontool.getOrderedSet()) #foreach ($v in $currentValues) #set ($discard = $extendedValue.add($v)) #end #set ($discard = $extendedValue.add($entry.value)) #set ($discard = $parameters.put($entry.key, $extendedValue)) #end #end #set ($queryString = $escapetool.url($parameters)) #set ($url = $NULL) #setVariable("$url" $doc.getURL('view', $queryString)) #end {code} |
|