VeggieMeat / search_api_elasticsearch

Clone of project at drupal.org/project/search_api_elasticsearch for better CI options than what D.O offers
16 stars 8 forks source link

Filter not working as expected #96

Open mllrmat opened 7 years ago

mllrmat commented 7 years ago

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!