Question

I have problems with faceting. Imagine this situation. Product can be in more than one category. This is common behavior for faceting:

Category

  • Android (25)
  • iPhone (55)
  • other (25)

Now when I select "Android", I make new query with "fq" => "category:Android", I will get:

Category

  • Android
  • iPhone (15)
  • other (2)

But this means that there is 15 products, that are in categories "Android" AND "iPhone". I would like something like this: ("Android" OR "iPhone")

Category

  • Android
  • iPhone (+5)
  • other (+1)

Meaning I will get 25 results by selecting "Android (25)" and another 5 by selecting "iPhone (+5)", so finally I will get 30 search results..

Does anyone know if this is possible with SOLR's faceting? Or perhaps with more than one query and calculate it manually?

Thanks for advice!

Was it helpful?

Solution

Try a new query with the negative of the selections, like "fq" => "-category:Android" - you should then get the facet counts you are looking for.

OTHER TIPS

Depending on all the permutations you need, you probably want to look into query facets that enable you to get counts for arbitrary queries. For instance, you can do facet.query=category:("Android" OR "iPhone") and get a count results keyed on category:("Android" OR "iPhone"). And, you can do this for any number of queries you want counts for. So, in your case, you can probably get to a final solution with some combination of straight field facets and query facets.

Edit: Re-reading you question, you may also want to look into tagging and excluding parts of an extra fq, depending on how you are allowing your users to "select into" the choices. (The example in the docs is fairly close to your original setup, although I'm not sure the end behavior is exactly as you desire).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top