I have a group
index. A group has two privacy types, public and private. A private group is associated with an access code. In the search result a private group should only be included if user has the access code associated to it. Previously private groups did not show in the search result, so I had one simple query !privacy_type:private
.
But now I have to include the private groups if user has the access code for that group (User can have multiple access codes and we have to include groups with those access codes). How to use conditional filter like this?
As long as there aren't multiple groups with the same access_code
and they should behave differently (i.e. if for an access_code
all groups with that access_code
should be returned):
fq=privacy_type:public OR access_code:(access_code_1 access_code_2 access_code_3)
You can also explicitly tell Solr to OR each statement inside the access_code
list - access_code:(access_code_1 OR access_code_2 OR ...)
, but you should be able to drop it in this case.
Solr has a default maximum number of boolean clauses as 1000, so as long as the number of access groups per user is lower than that, this should work fine.