0

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?

Community
  • 1
  • 1
Jamie Katz
  • 145
  • 2
  • 9

1 Answers1

1

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}*:*)
MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • The negative does seem to work, thank you. One thing I don't really understand is how to get a facet.field to reflect the 2 queries. – Jamie Katz Nov 09 '18 at 16:21
  • The results are included under the `"facet_queries" : {` key in the result. The usual `facet.field` argument also supports `{!key="with_parent"}fieldname` the change the output key - the queries might do the same - try it! – MatsLindh Nov 09 '18 at 18:15