0

We're running Apache Solr v3.1 and SolrJ is our client.

We're passing multiple Arbitrary Faceting Query (facet.query) to get the number of matching documents (the facet count) evaluated over the search results in a single Solr query. My use case demands the actual matching facet results/documents/fields also along with facet count.

My question is, is it possible to get facet query matching results along with facet count in a single Solr query call?

Gnanam
  • 10,613
  • 19
  • 54
  • 72
  • If only you tried :-) The documents are returned in `docs` and the facets are returned in `faceting` (alongside the docs). Do extract the HTTP calls SolrJ makes and run them in your browser. – Jesvin Jose Jul 16 '12 at 11:39
  • @aitchnyu: I think you've not understood my question. I knew documents are returned in `docs`, but my question here is I want to get facet count's results as well in single Solr query call. Hope I made this clear. – Gnanam Jul 17 '12 at 05:16

1 Answers1

2

There is no support to get the facet rows count in solr 3.1 to my knowledge. The issue you are looking for exists as a feature request in Solr's JIRA:

https://issues.apache.org/jira/browse/SOLR-2242

There is a patch available, even specifically for Solr 3.1, but the issue still remains unresolved / uncommitted in 4.0. Maybe you could apply the patch yourself and see how it works out.

spyk
  • 878
  • 1
  • 9
  • 26
  • Thanks for pointing to that link. I could see that the JIRA issue is being discussed with `facet.field`. Any idea or guess on whether this same patch is applicable for Arbitrary Query Faceting (`facet.query`) also? – Gnanam Jul 18 '12 at 05:34
  • Ok I misundestood, do you just need to get the facet.query results using SolrJ? Maybe this answers your question then: [http://stackoverflow.com/questions/1299732/how-to-retrieve-facet-queries-data-with-solrj](http://stackoverflow.com/questions/1299732/how-to-retrieve-facet-queries-data-with-solrj) – spyk Jul 18 '12 at 08:37
  • Still your initial understanding of my question is right. Anyhow, let me try to explain this with an example. For instance, if I've 2 facet queries (`facet.query`) which has 40 and 50 matching documents respectively. I want the documents (result) itself of each 40 and 50 counts that matched the facet query. I think the JIRA issue link provided by you have addressed my need for `facet.field`, but in my case, I'm using Arbitrary Query Faceting (`facet.query`). – Gnanam Jul 18 '12 at 09:39
  • 1
    OK, so you need the actual results to go along with the counts. I don't think that this is possible with the facet component (it just returns the counts). There is another feature, called Result Grouping / Field Collapsing [http://wiki.apache.org/solr/FieldCollapsing](http://wiki.apache.org/solr/FieldCollapsing) that might be useful for your case, although it appears after Solr 3.3. – spyk Jul 18 '12 at 11:21
  • Thanks for your comment. I'll try out *Result Grouping / Field Collapsing*. – Gnanam Jul 19 '12 at 04:59
  • Thanks, I tried that and I'm finding `Result Grouping / Field Collapsing` is the right solution to go with for my use case. Thanks again! – Gnanam Jul 19 '12 at 14:06