绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
Apache Solr 实现去掉重复的搜索结果
2020-02-13 19:12:11

https://lucene.apache.org/solr/guide/7_2/collapse-and-expand-results.html#collapsing-query-parser

对应的源码实现QParserPlugin

复制代码
static {
    HashMap<String, Class<? extends QParserPlugin>> map = new HashMap<>(30, 1);
    map.put(LuceneQParserPlugin.NAME, LuceneQParserPlugin.class);
    map.put(FunctionQParserPlugin.NAME, FunctionQParserPlugin.class);
    map.put(PrefixQParserPlugin.NAME, PrefixQParserPlugin.class);
    map.put(BoostQParserPlugin.NAME, BoostQParserPlugin.class);
    map.put(DisMaxQParserPlugin.NAME, DisMaxQParserPlugin.class);
    map.put(ExtendedDismaxQParserPlugin.NAME, ExtendedDismaxQParserPlugin.class);
    map.put(FieldQParserPlugin.NAME, FieldQParserPlugin.class);
    map.put(RawQParserPlugin.NAME, RawQParserPlugin.class);
    map.put(TermQParserPlugin.NAME, TermQParserPlugin.class);
    map.put(TermsQParserPlugin.NAME, TermsQParserPlugin.class);
    map.put(NestedQParserPlugin.NAME, NestedQParserPlugin.class);
    map.put(FunctionRangeQParserPlugin.NAME, FunctionRangeQParserPlugin.class);
    map.put(SpatialFilterQParserPlugin.NAME, SpatialFilterQParserPlugin.class);
    map.put(SpatialBoxQParserPlugin.NAME, SpatialBoxQParserPlugin.class);
    map.put(JoinQParserPlugin.NAME, JoinQParserPlugin.class);
    map.put(SurroundQParserPlugin.NAME, SurroundQParserPlugin.class);
    map.put(SwitchQParserPlugin.NAME, SwitchQParserPlugin.class);
    map.put(MaxScoreQParserPlugin.NAME, MaxScoreQParserPlugin.class);
    map.put(BlockJoinParentQParserPlugin.NAME, BlockJoinParentQParserPlugin.class);
    map.put(BlockJoinChildQParserPlugin.NAME, BlockJoinChildQParserPlugin.class);
    map.put(CollapsingQParserPlugin.NAME, CollapsingQParserPlugin.class);
    map.put(SimpleQParserPlugin.NAME, SimpleQParserPlugin.class);
    map.put(ComplexPhraseQParserPlugin.NAME, ComplexPhraseQParserPlugin.class);
    map.put(ReRankQParserPlugin.NAME, ReRankQParserPlugin.class);
    map.put(ExportQParserPlugin.NAME, ExportQParserPlugin.class);
    map.put(MLTQParserPlugin.NAME, MLTQParserPlugin.class);
    map.put(HashQParserPlugin.NAME, HashQParserPlugin.class);
    map.put(GraphQParserPlugin.NAME, GraphQParserPlugin.class);
    map.put(XmlQParserPlugin.NAME, XmlQParserPlugin.class);
    map.put(GraphTermsQParserPlugin.NAME, GraphTermsQParserPlugin.class);
    map.put(IGainTermsQParserPlugin.NAME, IGainTermsQParserPlugin.class);
    map.put(TextLogisticRegressionQParserPlugin.NAME, TextLogisticRegressionQParserPlugin.class);
    map.put(SignificantTermsQParserPlugin.NAME, SignificantTermsQParserPlugin.class);
    map.put(PayloadScoreQParserPlugin.NAME, PayloadScoreQParserPlugin.class);
    map.put(PayloadCheckQParserPlugin.NAME, PayloadCheckQParserPlugin.class);
    map.put(BoolQParserPlugin.NAME, BoolQParserPlugin.class);

    standardPlugins = Collections.unmodifiableMap(map);
  }
复制代码

具体如下:

复制代码
/**

 The <b>CollapsingQParserPlugin</b> is a PostFilter that performs field collapsing.
 This is a high performance alternative to standard Solr
 field collapsing (with ngroups) when the number of distinct groups
 in the result set is high.
 <p>
 Sample syntax:
 <p>
 Collapse based on the highest scoring document:
 <p>

 fq=(!collapse field=field_name}

 <p>
 Collapse based on the min value of a numeric field:
 <p>
 fq={!collapse field=field_name min=field_name}
 <p>
 Collapse based on the max value of a numeric field:
 <p>
 fq={!collapse field=field_name max=field_name}
 <p>
 Collapse with a null policy:
 <p>
 fq={!collapse field=field_name nullPolicy=nullPolicy}
 <p>
 There are three null policies: <br>
 ignore : removes docs with a null value in the collapse field (default).<br>
 expand : treats each doc with a null value in the collapse field as a separate group.<br>
 collapse : collapses all docs with a null value into a single group using either highest score, or min/max.
 <p>
 The CollapsingQParserPlugin fully supports the QueryElevationComponent
 **/
复制代码
分享好友

分享这个小栈给你的朋友们,一起进步吧。

凉城时光
创建时间:2019-12-04 10:57:57
朋友 我们一起聊运维
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

栈主、嘉宾

查看更多
  • 我没
    栈主

小栈成员

查看更多
  • unnamed personq
  • unnamed personq
  • bluetooth
  • amadan
戳我,来吐槽~