: prod1 has tag called “Light Weight” with weightage 20, : prod2 has tag called “Light Weight” with weightage 100, : : If i get facet for “Light Weight” , i will get Light Weight (2) , : here i need to consider the weightage in to account, and the result will be : Light Weight (120) : : How can we achieve this?Any ideas are really helpful.
It's not really possible with Solr out of the box. Faceting is fast and efficient in Solr because it's all done using set intersections (and most of the sets can be kept in ram very compactly and reused). For what you are describing you'd need to no only assocaited a weighted payload with every TermPosition, but also factor that weight in when doing the faceting, which means efficient set operations are now out the window. If you know java it would be probably be possible to write a custom SolrPlugin (a SearchComponent) to do this type of faceting in special cases (assuming you indexed in a particular way) but i'm not sure off hte top of my head how well it would scale -- the basic algo i'm thinking of is (after indexing each facet term wit ha weight payload) to iterate over the DocSet of all matching documents in parallel with an iteration over a TermPositions, skipping ahead to only the docs that match the query, and recording the sum of the payloads for each term. Hmmm... except TermPositions iterates over <term, <doc, freq, <position>>> tuples, so you would have to iterate over every term, and for every term then loop over all matching docs ... like i said, not sure how efficient it would wind up being. You might be happier all arround if you just do some sampling -- store the tag+weight pairs so thta htey cna be retireved with each doc, and then when you get your top facet constraints back, look at the first page of results, and figure out what the sun "weight" is for each of those constraints based solely on the page#1 results. i've had happy users using a similar appraoch in the past. -Hoss