Reputation: 881
How to add more fields in facet other than default ones using SOLR? Like solr is returning that facet field and count in the facet but i want to get other fields also along with the facets. Please help
For Eg:- If i have to make a category facet, the SOLR will return only category name and count in the facet. so if i want to add one more field like category_id also with that facet how can i do that?
Edit :- I want category facets like this format.
category: [ { name: "Mobiles", numDocs: 1002, category_id: 1719 }, { name: "Batteries", numDocs: 543, category_id: 1533, } ]
Upvotes: 1
Views: 585
Reputation: 544
The solution is to use "appends" instead of "defaults" in the solrconfig file
This is an example:
<lst name="appends">
<str name="facet.field">field1</str>
<str name="facet.field">field2</str>
</lst>
The point is that with any section marked as "defaults", it means that these are the default values, and if the value is not provided in the URL the default value is used. However if the value is passed through the URL then these values are ignored.
What you need to do as I understand is the other way around. You want to provide an optional value from the url, and still be able to append values from the config file. So, in this case you put your configurations in a "appends" section, not "defaults". Because defaults are overwritten by url params.
Cheers.
Upvotes: 0
Reputation: 9789
Did you have a look at the facet parameters documentation?
I cannot quite understand your question, but I suspect looking at facet.query and tagging and excluding filters may be the right direction to research.
Upvotes: 0