编程语言
首页 > 编程语言> > java – SOLR – PathHierarchyTokenizerFactory Facet Query

java – SOLR – PathHierarchyTokenizerFactory Facet Query

作者:互联网

我一直在尝试对配置为solr.PathHierarchyTokenizerFactory的字段执行查询,但查询只返回所有记录.似乎做一个facet查询是行不通的.有没有人有办法完成这个?我正在使用PathHierarchy来实现category / subcategory facets.

<fieldType name="text_path" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
        <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
    </analyzer>
</fieldType>

<field name="libraries" type="text_path" indexed="true" stored="true" multiValued="true" />

HTTP:// linux2上:8984 / solr的/选择Q = *:*&安培;行= 0&安培; FQ =库: “/测试/分测验” &安培;小面=真安培; facet.field =文库&安培; f.libraries.facet的.sort =真安培; f.libraries.facet.limit = -1&安培; f.libraries.facet.mincount = -1

谢谢

解决方法:

更改text_path字段定义以仅在索引时应用PathHierarchyTokenizerFactory(下面的示例).您的问题是,您的查询正由令牌化程序处理,以便fq = libraries:“/ test / subtest”实际上是针对fq = libraries查询:(/ test / subtest OR / test).

<fieldType name="text_path" class="solr.TextField" positionIncrementGap="100">
    <analyzer type="index">
        <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
    </analyzer>
</fieldType>

请注意分析仪类型=“索引”

标签:solrnet,faceted-search,java,lucene,solr
来源: https://codeday.me/bug/20190726/1542184.html