Faceted Search
Faceted search is useful to do count(*) feature, please see below examples for your reference:
Count(*) by Specified Field
When browsing this page : http://localhost:8983/solr/films/browse , you may find Facets field on the left handset as:
With below example, it will return you a list of genres with article counts, so that you can show on your application.
Requested URL | ||
Details | ||
It will return a list of genres with article counts, e.g. it has 23 articles as Drama genre. |
||
Parameters | Values | Details |
facet | true | Enable facet feature |
facet.field | genre | Facet Field, something like “GROUP BY” clause in SQL:
SELECT count(*) FROM table GROUP BY “facet.field” |
rows | 0 | Optional, returning number of rows |
You can also use this one returning list of directed_by with article counts.
Requested URL | ||
http://localhost:8983/solr/films/admin/luke?fl=directed_by&numTerms=50 |
||
Details | ||
E.g. it has 5 articles as “Ridley Scott” directed_by. |
||
Parameters | Values | Details |
fl | directed_by | Field for top terms |
numTerms | 50 | Return number of terms |
With Date Range
Facets search can be bounded by date range like:
Requested URL | ||
Details | ||
It will return a list of dates with article counts, with the field “initial_release_date” range from facet.range.start=2000-02-01T00:00:01Z to facet.range.end =2001-02-01T00:00:01Z with one month (+1MONTH ) range gap. |
||
Parameters | Values | Details |
facet.range | initial_release_date | Field for facet range |
facet.range.start | 2000-02-01T00:00:01Z | Start date for ranging |
facet.range.end | 2001-02-01T00:00:01Z | End date for ranging |
facet.range.gap | +1MONTH | Range gap duration |
With Integer Range
Besides Date range facets, it can be bounded by integer range like:
Requested URL | ||
Details | ||
It will return a list of dates with article counts, with the field “_version_” range from facet.range.start=1510000000000000000 to facet.range.end =1530000000000000000 with range gap 1000000000000000. |
||
Parameters | Values | Details |
facet.range | _version_ | Field for facet range |
facet.range.start | 1510000000000000000 | Start value for ranging |
facet.range.end | 1530000000000000000 | End value for ranging |
facet.range.gap | 1000000000000000 | Range gap duration |