0
votes

I'm working on improving search which is powered by solr for my e-commerce project. So search queries are performed into Solr and results are returned by Solr.

This is working fine. Now I need to offer a facet on the search results. The first could be category this is easy to implement as Category is common to all product and in the query I make I just enable facet and pass category as facet field.

However, for different nature of products there could be different products and they have few facets defined for them.

I'm clueless as how would I know them in advance and pass it in solr search query? Does solr return all facet field by some queries along with the search results? If yes, how?

If no, then what could be the correct way to proceed further.

3
Not sure I get the question. Can you please provide us with some examples ?Jayendra

3 Answers

0
votes

Define all the static fieldnames in your facet query search, if there are no hits you will not get any results back for that field.

0
votes

Pass all the possible fields(on which u need faceting) in Facet Field with facet.mincount=1.. so, you'll get only those fields which has at-least one occurrence in your solr data

http://<hostname>:<portname>/solr/<core_name>/select?q:<fieldname>:<value>&fq=<field_name>:<value>&fl=<field1>,<field2>,<fieldn>&start=0&rows=10&facet=true&facet.field=<field1>&facet.field=<field2>&facet.field=<fieldn>&facet.mincount=1
0
votes

Pass all Unique Facet Field Name on which you want to make facet filtering, and you will get all records that have facet field.