Reputation: 20856
I need to a faceted search on a particular column and drill down within its results.
Here is my schema.
State ZipCode PersonName
CA 12345 Tom
CA 12345 Mike
CA 23458 John
CA 23458 Lucy
I tried writing a facet query
http://localhost:8983/solr/query?facet=on&facet.field=State and it facets only based on State.
How do I include Zip code within it, so that I can drill down based on State & Zip code
Upvotes: 0
Views: 60
Reputation: 52822
You can do this two ways, depending on what you want.
If you just want to include a ZipCode facet as well, in addition to the State facet, add another facet.field
parameter: &facet.field=ZipCode
. That way you'll get facets for both fields in your response. The facets will be modified depending on your query results and filter queries, so if the user selects a State first, the fq= will make the ZipCode facet only return facet values within that state. You might also want to look at Tagging and excluding filters, if you want to show a count of all States, regardless of one being chosen at the moment.
Another option is to use facet.pivot
to get a two-dimensional table with facet values; for each state, get the count of the zipcodes in that state. &facet.pivot=State,ZipCode
.
Upvotes: 1