Hello,

I'm testing block join in solr 4.6.1 and wondering, is it possible to get facets for fields in subdocuments with number of hits based on ROOT documents?

See example below:

<doc>
    <documentPart>ROOT</documentPart>
    <text>testing 123</text>
    <title>title</test>
    <group>GRP</group>
    <subdocument>
        <field3>khat</field3>
        <field4>7000</field4>
        <field5>purchase</field5>
    </subdocoment>
    <subdocument>
        <field3>cannabis</field3>
        <field4>500</field4>
        <field5>sale</field5>
    </subdocoment>
</doc>

My query looks like this:

        solrQuery.setQuery("text:testing");
solrQuery.setFilterQueries("{!parent which=\"dokumentPart:ROOT\"}field3:khat");
        solrQuery.setFacet(true);
        solrQuery.addFacetField("group","field5");

This does not give me any facets for the subdocument fields, so i'm thinking, could a solution be to execute a second query to get the facets for the subdocument by join from parent to child whith a {!child of=} query like this:

    solrQuery.setQuery("{!child of=\"dokumentPart:ROOT\"}text:testing");
    solrQuery.setFilterQueries("field3:khat");
    solrQuery.setFacet(true);
    solrQuery.addFacetField("field5","field4", "field3");

The problem with this method is that the facet count will be based on sub documents and not ROOT/parent documents...

Is there a silver bullet for this kind of requirement?

Yours faithfully

Henning Solberg

Reply via email to