38

I need to return only the facet counts from solr. So I basically want to search over all documents and return the facet counts, but I don't want to return any search results. Is this possible?

Thanks

Ryan
  • 4,671
  • 4
  • 23
  • 21

3 Answers3

58

Setting facet=true will enable faceting and setting rows=0 will prevent any results being returned. Conveniently the numFound will show you how many results were found.

d-_-b
  • 21,536
  • 40
  • 150
  • 256
nialloc
  • 1,183
  • 1
  • 13
  • 24
10

I guess the obvious solution would be to search using a wildcard and specify that you want zero results returned.

That's my solution so far.

James McMahon
  • 48,506
  • 64
  • 207
  • 283
Ryan
  • 4,671
  • 4
  • 23
  • 21
  • 2
    Returning zero results along with a wildcard on the id field is going to be the easiest. – Andrew Ingram Oct 20 '08 at 11:13
  • There's nothing in the question to suggest that wildcard is the correct query; or that any particular field should be constrained to any specific value or set of values. – jpaugh Nov 05 '20 at 22:57
0

So, from what I have understood if I need to get facets count for all documents in a paginated system, I need to make two requests (selects):
- The first to get the facets count for all documents.
- And the second to get the documents from current page.

Hakim
  • 3,225
  • 5
  • 37
  • 75