search_api_elasticsearch icon indicating copy to clipboard operation
search_api_elasticsearch copied to clipboard

Filter not working as expected

Open mllrmat opened this issue 7 years ago • 0 comments

I have a large index of items, and would like to add an access control mechanism for items on properties of individual users. Until now I had this implemented as filters in preprocessSearchQuery(), which was working all right with Version 7.x-1.x Now I migrated to 7.x-2.x and the filters are not working any more. They just do not get processed.

class SearchApiGroupAccess extends SearchApiAbstractProcessor { 

      public function preprocessSearchQuery(SearchApiQuery $query) {

		$filter = $query->getFilter();

		$groupFilter = $query->createFilter('OR');
				
 		$publicGroupsFilter = $query->createFilter('AND');
 		$publicGroupsFilter->condition('visibility', 'c');
 		$publicGroupsFilter->condition('privacy', 'o');
 		$groupFilter->filter($publicGroupsFilter);

		//more filters are added ...

                $filter->filter($groupFilter);
      }
}

How would you solve such a scenario in the new version?

Thank you!

mllrmat avatar Mar 16 '17 17:03 mllrmat