Facet字段值与anagram一起多次返回相同的值

时间:2016-04-13 10:19:00

标签: java solr solrj facet

我正在尝试从solr获取字段的唯一值。我使用facet来获取字段值。我的facet查询参数看起来像 -

        SolrQuery query = new SolrQuery();
        query.setQuery("*:*");
        query.setFacet(true);
        query.addFacetField("division");

我正在使用 -

打印构面值
resp = solrClient.query(query);

            List<FacetField> fflist = resp.getFacetFields();
            for(FacetField ff : fflist){
                String ffname = ff.getName();

                int ffcount = ff.getValueCount();

                System.out.println(ffname+" "+ffcount);
                List<Count> counts = ff.getValues();
                for(Count c : counts){
                    String facetLabel = c.getName();
                    long facetCount = c.getCount();

                    System.out.println("facetlabel-->"+facetLabel+" facetcount-->"+facetCount);
                }
            }

我正在接受以下回复 -

facetlabel-->seirossecca facetcount-->184
facetlabel-->accessori facetcount-->184
facetlabel-->seirossecca facetcount-->184
facetlabel-->cinht facetcount-->116
facetlabel-->cinht facetcount-->116
facetlabel-->ethnic facetcount-->116
facetlabel-->spot facetcount-->851
facetlabel-->spot facetcount-->851
facetlabel-->top facetcount-->851
facetlabel-->raewtoof facetcount-->577
facetlabel-->footwear facetcount-->577
facetlabel-->raewtoof facetcount-->577
facetlabel-->smottob facetcount-->387602
facetlabel-->bottom facetcount-->387602
facetlabel-->smottob facetcount-->387602
facetlabel-->ytuaeb facetcount-->354158
facetlabel-->beauti facetcount-->354158
facetlabel-->ytuaeb facetcount-->354158
facetlabel-->scinortcel facetcount-->204244
facetlabel-->electron facetcount-->204244
facetlabel-->scinortcel facetcount-->204244
facetlabel-->sesserd facetcount-->161
facetlabel-->dress facetcount-->161
facetlabel-->sesserd facetcount-->161

正如您所看到的,我正在使用单独的条目获取分面字段的字谜但相应的字段值相同。分部属于

类型
  

text_search

schema.xml中的文本搜索定义是 -

<fieldType name="text_search" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true" multiValued="true">
        <analyzer type="index">
          <tokenizer class="solr.WhitespaceTokenizerFactory"/>
          <filter class="solr.LowerCaseFilterFactory"/>
          <filter class="solr.ReversedWildcardFilterFactory"/>
          <filter class="solr.PorterStemFilterFactory"/>
          <filter class="solr.WordDelimiterFilterFactory" splitOnNumerics="0" generateWordParts="1" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="1" splitOnCaseChange="0" preserveOriginal="1"/>
          <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
        </analyzer>
        <analyzer type="query">
          <tokenizer class="solr.WhitespaceTokenizerFactory"/>
          <filter class="solr.LowerCaseFilterFactory"/>
          <filter class="solr.PorterStemFilterFactory"/>
          <filter class="solr.ReversedWildcardFilterFactory"/>
          <filter class="solr.WordDelimiterFilterFactory" splitOnNumerics="0" generateWordParts="1" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="1" splitOnCaseChange="0" preserveOriginal="1"/>
          <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
        </analyzer>
    </fieldType>

1 个答案:

答案 0 :(得分:2)

这是因为您使用的是ReversedWildcardFilterFactory

ReversedWildcardFilterFactory:反转令牌的过滤器。

同样的事情发生在你身上..

seirosseccaaccessories相反 accessories由于accessori而被缩短为PorterStemFilterFactory,因为它会从单词中删除常见的结尾。

为避免这种情况,您可以从ReversedWildcardFilterFactory移除schema.xml

PorterStemFilterFactory :
如果想要从单词中删除常见结尾,

留给你。