SOLR - PathHierarchyTokenizerFactory 分面查询

4

我一直在尝试对一个配置为solr.PathHierarchyTokenizerFactory的字段进行查询,但查询只返回所有记录。似乎无法执行facets查询。有人知道如何实现吗?我正在使用PathHierarchy来实现类别/子类别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" />

And

http://linux2:8984/solr/select?q=*:*&rows=0&fq=libraries:"/test/subtest"&facet=true&facet.field=libraries&f.libraries.facet.sort=true&f.libraries.facet.limit=-1&f.libraries.facet.mincount=-1

Thanks

2个回答

10

将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>

注意分词器类型为 "Index"


0
如果删除分面参数会发生什么?它是否也会返回所有文档?
从我的观点来看,分面不应该对搜索结果产生影响。我觉得你在fq参数中传递的过滤查询由于某些原因没有起作用。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接