Krunal
Krunal

Reputation: 3269

Solr Exclude Filter for Category

Using Solr 6, for e-commerce catalog with search and filtering.

I need to exclude all products for certain category? Not sure how to do that in Solr. Can you give some idea, how can we achieve that?

Note that, CategoryID is a multi valued string field, as one product can be assigned to multiple categories.

Upvotes: 2

Views: 2288

Answers (1)

Romain Meresse
Romain Meresse

Reputation: 3044

Use the boolean "NOT" operator.

* NOT CategoryID:111

Alternative syntax :

* -CategoryID:111
* !CategoryID:111

Documentation : https://cwiki.apache.org/confluence/display/solr/The+Standard+Query+Parser#TheStandardQueryParser-BooleanOperatorsSupportedbytheStandardQueryParser

Upvotes: 1

Related Questions