Solr complex cut

I have problems with the cut. Imagine this situation. The product may be in several categories. This is the usual behavior for cutting:

Category

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

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

Category

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

But this means that there are 15 products that are in the categories of โ€œAndroidโ€ and โ€œiPhoneโ€. I would like something like this: ("Android" or "iPhone")

Category

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

Value 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 a SOLR cut? Or perhaps with multiple queries and compute it manually?

Thanks for the advice!

+4
source share
2 answers

Try a new query with the negation of the selected options, for example, "fq" => "-category:Android" - you should get the number of faces that you are looking for.

+3
source

Depending on all the permutations that you need, you will probably want to study aspects of the question that allow you to get calculations for arbitrary queries. For example, you can do facet.query=category:("Android" OR "iPhone") and get the count results using category:("Android" OR "iPhone") . And you can do this for any number of queries for which you want to count. Thus, in your case, you can probably go to the final solution with some combination of direct phase faces and aspects of the request.

Change Repeating the question, you can also view the marking and exclusion of parts of extra fq , depending on how you allow your users to โ€œchooseโ€ a choice. (The example in the docs is pretty close to your initial setup, although I'm not sure if the final behavior is exactly as you wish).

+3
source

Source: https://habr.com/ru/post/1383918/


All Articles