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
Change comment: Install extension [org.xwiki.platform:xwiki-platform-search-solr-ui/9.11.7]
To version 2.1
edited by Administrator
on 2019/11/04 23:53
Change comment: Install extension [org.xwiki.platform:xwiki-platform-search-solr-ui/10.11.9]

Summary

Details

Page properties
Content
... ... @@ -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))
... ... @@ -727,11 +727,11 @@
727 727   #end
728 728   ##
729 729   ## Pagination
730 - #set ($rows = $numbertool.integer($request.rows))
782 + #set ($rows = $mathtool.toInteger($request.rows))
731 731   #if ("$!rows" == '')
732 732   #set ($rows = 10)
733 733   #end
734 - #set ($start = $numbertool.integer($request.firstIndex))
786 + #set ($start = $mathtool.toInteger($request.firstIndex))
735 735   #if ("$!start" == '')
736 736   #set ($start = 0)
737 737   #end