zoukankan      html  css  js  c++  java
  • Apache Solr 实现去掉重复的搜索结果

    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
     **/
  • 相关阅读:
    3709: [PA2014]Bohater
    T89379 【qbxt】复读警告
    T89353 【BIO】RGB三角形
    T89359 扫雷
    P1325 雷达安装
    P2983 [USACO10FEB]购买巧克力
    DP----鬼畜的数字三角形
    提高组突破嘤
    数据结构题目大赏 (一堆题目没做)
    DAY 3
  • 原文地址:https://www.cnblogs.com/davidwang456/p/10490896.html
Copyright © 2011-2022 走看看