3
votes

Solr returns each facet as a collection of name/count pairs (wrapped in a FacetField). In my faceted search app I would use these as follows.

Audi (2)
Honda (5)
Mitsubishi (6)
Mercedes Benz (8)

Now I would like to turn this into a list of links. I could create URLs like

http://www.example.com/category=Mercedes%20Benz

That would work, but I would much rather have

http://www.example.com/category=4

That is, I would like to use the database ID of the categories/brands instead of their names.

Can I somehow link fields in Solr, so that I can link the category name to the category ID and have them both returned from my query? Or should I use a multivalued field and store the category name and id together?

Your advice is most welcome :)

2

2 Answers

2
votes

You can check for Solr pivot as well which will return the Category Name and the Category Id as parent child facet hierarchy which in you case will always be one to one match.

1
votes

I have an idea. You can define a new field which joins category id and category name together. Just like express below.

1_Audi, 2_Honda, 3_Mitsubishi ,4_Mercedes Benz

Faceting on the new field will get result like this,

1_Audi(2)
2_Honda(3)
3_Mitsubishi(4)
4_Mercedes Benz(5)

You can split them laterly to get both category id and name. Name for disply while id for link.