Jamie Katz
Jamie Katz

Reputation: 145

Solr Facet for "related records"

I'm working on a Solr system that has parent/children items in the index:

id="id":"123456",
ss_type:"parent"

&

ss_parent_id=:"123456",
ss_type:"child"

How do I create a Facet showing Parent items that have children and Parent items that have no children?

I think this query gives me the results:

q={!join from=ss_parent_id to=id} *:*

But can I make that a facet that returns something like:

With Children: 201

Without Children: 109

If not, is there a work-around?

Upvotes: 0

Views: 216

Answers (1)

MatsLindh
MatsLindh

Reputation: 52892

You should be able to use Facet queries for this, as you can give the query parser there as well - in the same way as in your example.

facet.query={!join from=ss_parent_id to=id}*:*

The inverse might be harder, but according to an earlier answer, there might be an option to prefix the query parser with - (I didn't think this would work, so please try it out):

facet.query=*:* -({!join from=ss_parent_id to=id}*:*)

Upvotes: 1

Related Questions