Changes for page Solr Search Macros
Last modified by Administrator on 2025/09/06 09:59
From version 1.1

edited by Administrator
on 2018/07/24 00:25
on 2018/07/24 00:25
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-search-solr-ui/9.11.7]
To version
3.1


edited by Administrator
on 2020/12/29 00:17
on 2020/12/29 00:17
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-search-solr-ui/12.10.2]
Summary
Details
- Page properties
-
- Content
-
... ... @@ -214,7 +214,7 @@ 214 214 215 215 #macro (displaySearchFacetValuesLimited $facetValues $customQueryStringParameters $customValueDisplayer) 216 216 #set ($limitRequestParameter = "l_$facetField.name") 217 - #set ($limit = $m athtool.toInteger($request.getParameter($limitRequestParameter)))217 + #set ($limit = $numbertool.toNumber($request.getParameter($limitRequestParameter)).intValue()) 218 218 #if ("$!limit" == '') 219 219 #set ($limit = $solrConfig.facetPaginationStep) 220 220 #end ... ... @@ -298,9 +298,9 @@ 298 298 (% class="search-options" %) 299 299 * {{translation key="solr.options"/}} 300 300 #if($highlightEnabled)#extendQueryString($url {'highlight': [false]})#else#extendQueryString($url {'highlight': [true]})#end 301 - * [[{{translation key="solr.options.highlight"/}}>>path:$url||class="options-item#if($highlightEnabled) active#end" title="$services.localization.render('solr.options.highlight.title')"]] 301 + * [[{{translation key="solr.options.highlight"/}}>>path:${url}||class="options-item#if($highlightEnabled) active#end" title="$services.localization.render('solr.options.highlight.title')"]] 302 302 #if($facetEnabled)#extendQueryString($url {'facet': [false]})#else#extendQueryString($url {'facet': [true]})#end 303 - * [[{{translation key="solr.options.facet"/}}>>path:$url||class="options-item#if($facetEnabled) active#end" title="$services.localization.render('solr.options.facet.title')"]] 303 + * [[{{translation key="solr.options.facet"/}}>>path:${url}||class="options-item#if($facetEnabled) active#end" title="$services.localization.render('solr.options.facet.title')"]] 304 304 305 305 (% class="search-results-sort" %) 306 306 * {{translation key="solr.sortBy"/}} ... ... @@ -315,7 +315,7 @@ 315 315 #set ($targetSortOrder = "#if ($sortOrder == 'asc')desc#{else}asc#end") 316 316 #end 317 317 #extendQueryString($url {'sort': [$entry.key], 'sortOrder': [$targetSortOrder]}) 318 - * [[{{translation key="solr.sortBy.$entry.key"/}}$!sortOrderIndicator>>path:$url||class="$class"]] 318 + * [[{{translation key="solr.sortBy.$entry.key"/}}$!sortOrderIndicator>>path:${url}||class="$class"]] 319 319 #end 320 320 #end 321 321 ... ... @@ -561,7 +561,7 @@ 561 561 'matches': $matches 562 562 })) 563 563 #end 564 - #set ($highlighting = $ sorttool.sort($highlighting, 'priority:desc'))564 + #set ($highlighting = $collectiontool.sort($highlighting, 'priority:desc')) 565 565 #set ($return = $NULL) 566 566 #setVariable("$return" $highlighting) 567 567 #end ... ... @@ -576,7 +576,10 @@ 576 576 #set ($discard = $query.setLimit($rows)) 577 577 #set ($discard = $query.setOffset($start)) 578 578 #set ($discard = $query.bindValue('sort', "${sort} ${sortOrder}")) 579 + #set ($discard = $query.bindValue('tie', $solrConfig.tieBreaker)) 580 + #set ($discard = $query.bindValue('mm', $solrConfig.minShouldMatch)) 579 579 #setQueryFields($query) 582 + #setPhraseFields($query) 580 580 #setFacetFields($query) 581 581 #setFilterQuery($query) 582 582 #setHighlightQuery($query) ... ... @@ -604,6 +604,55 @@ 604 604 #set ($discard = $query.bindValue('qf', $boost)) 605 605 #end 606 606 #end 610 + 611 +#macro (setPhraseFields $query) 612 + ## Set the main phrase field parameter boosts so that queries with all search terms 613 + ## in close proximity have high relevance 614 + #if ($solrConfig.phraseFields.substring(0, 0) == '') 615 + ## If the value of the 'phraseFields' parameter is a string then it means that the 616 + ## same query fields are used for all result types. 617 + #set ($phraseFieldsBoost = $solrConfig.phraseFields) 618 + #else 619 + ## There are different phrase fields for each result type. 620 + ## Including type = null, which will result from all facets being deselected 621 + #set ($phraseFieldsBoost = $solrConfig.phraseFields.get("$!type")) 622 + #end 623 + #if ("$!phraseFieldsBoost" != '') 624 + #set ($discard = $query.bindValue('pf', $phraseFieldsBoost)) 625 + #set ($discard = $query.bindValue('ps', $solrConfig.phraseFieldSlop)) 626 + #end 627 + ## Set the bigram phrase field parameter boosts so that queries with groups of two 628 + ## search terms in close proximity have high relevance 629 + #if ($solrConfig.bigramPhraseFields.substring(0, 0) == '') 630 + ## If the value of the 'bigramPhraseFields' parameter is a string then it means that the 631 + ## same query fields are used for all result types. 632 + #set ($bigramPhraseFieldsBoost = $solrConfig.bigramPhraseFields) 633 + #else 634 + ## There are different phrase fields for each result type. 635 + ## Including type = null, which will result from all facets being deselected 636 + #set ($bigramPhraseFieldsBoost = $solrConfig.bigramPhraseFields.get("$!type")) 637 + #end 638 + #if ("$!bigramPhraseFieldsBoost" != '') 639 + #set ($discard = $query.bindValue('pf2', $bigramPhraseFieldsBoost)) 640 + #set ($discard = $query.bindValue('ps2', $solrConfig.bigramPhraseFieldSlop)) 641 + #end 642 + ## Set the trigram phrase field parameter boosts so that queries with groups of three 643 + ## search terms in close proximity have high relevance. 644 + ## Generally (pf boost) > (pf3 boost) > (pf2 boost) 645 + #if ($solrConfig.trigramPhraseFields.substring(0, 0) == '') 646 + ## If the value of the 'trigramPhraseFields' parameter is a string then it means that the 647 + ## same query fields are used for all result types. 648 + #set ($trigramPhraseFieldsBoost = $solrConfig.trigramPhraseFields) 649 + #else 650 + ## There are different phrase fields for each result type. 651 + ## including type = null, which will result from all facets being deselected 652 + #set ($trigramPhraseFieldsBoost = $solrConfig.trigramPhraseFields.get("$!type")) 653 + #end 654 + #if ("$!trigramPhraseFieldsBoost" != '') 655 + #set ($discard = $query.bindValue('pf3', $trigramPhraseFieldsBoost)) 656 + #set ($discard = $query.bindValue('ps3', $solrConfig.trigramPhraseFieldSlop)) 657 + #end 658 +#end 607 607 608 608 #macro (setFacetFields $query) 609 609 #set ($discard = $query.bindValue('facet', $facetEnabled)) ... ... @@ -663,7 +663,7 @@ 663 663 #set ($discard = $filters.put($fieldName, $escapedValues)) 664 664 #if ($prefixFacets.contains($fieldName)) 665 665 #set ($parts = $parameter.value.get(0).split('/', 2)) 666 - #set ($length = $m athtool.toInteger($parts.get(0)) + 1)718 + #set ($length = $numbertool.toNumber($parts.get(0)).intValue() + 1) 667 667 #set ($prefix = "$length/$parts.get(1)") 668 668 #set ($discard = $query.bindValue("f.${fieldName}.facet.prefix", $prefix)) 669 669 #set ($discard = $prefixFacets.remove($fieldName)) ... ... @@ -727,11 +727,11 @@ 727 727 #end 728 728 ## 729 729 ## Pagination 730 - #set ($rows = $numbertool. integer($request.rows))782 + #set ($rows = $numbertool.toNumber($request.rows).intValue()) 731 731 #if ("$!rows" == '') 732 732 #set ($rows = 10) 733 733 #end 734 - #set ($start = $numbertool. integer($request.firstIndex))786 + #set ($start = $numbertool.toNumber($request.firstIndex).intValue()) 735 735 #if ("$!start" == '') 736 736 #set ($start = 0) 737 737 #end