码迷,mamicode.com
首页 > Web开发 > 详细

Apache Solr 实现去掉重复的搜索结果

时间:2019-03-07 17:46:24      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:this   range   groups   prefix   either   remove   for   string   form   

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
 **/

 

Apache Solr 实现去掉重复的搜索结果

标签:this   range   groups   prefix   either   remove   for   string   form   

原文地址:https://www.cnblogs.com/davidwang456/p/10490896.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!