Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOLR - PathHierarchyTokenizerFactory Facet Query

I have been trying to perform a query on a field that is configured to be solr.PathHierarchyTokenizerFactory, but the query just returns all records. It seems that doing a facet query is just not working. Does anyone have a way of accomplishing this? I'm using the PathHierarchy to implement 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" />

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

like image 747
Vince Avatar asked Dec 27 '22 16:12

Vince


1 Answers

Change your text_path field definition to apply the PathHierarchyTokenizerFactory at index time only (example below). Your issue is that your queries are being processed by the tokenizer so that fq=libraries:"/test/subtest" actually queries against 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>

Note the analyzer type="Index"

like image 152
Kenneth Ito Avatar answered Jan 08 '23 10:01

Kenneth Ito