multi-dimensional facets

37 views
Skip to first unread message

Theo

unread,
Oct 19, 2015, 9:06:19 PM10/19/15
to Sunspot
I have been looking around to find the best approach to solving how I can drill down  a hierarchical structure using facets in sunspot/solr.

Here is the problem:

I have an active record model that is indexed. 
Within that model I have multiple "tags" that can be associated to. 
These tags are really routes within a navigational structure e.g. shopping/photos , and as such are hierarchical. They can go four levels deep at this point. 
I would like to be able to use facets to "drill-down" this structure. e.g. only shopping/*.


One solution I came across is to flatten the structure e.g. in the document, de-normalize the hierarchy so you define the each level as a separate field, to me this appears clunky. But i guess will solve the problem, is there a better way?




James

unread,
Oct 20, 2015, 3:24:22 PM10/20/15
to Sunspot
What about making the indexed field multiple, and indexing each level, so that the indexed data (in Ruby-land) would look something like

[
  "shopping",
  "shopping/photos",
  "shopping/photos/cats",
  "shopping/photos/cats/inspirational"
]

Maybe that will let you facet on it get the counts for each level?
Reply all
Reply to author
Forward
0 new messages