0

I have created an indexed view, for facet search. Now I want to put a text field from which search provides a result, that contains that string from the title.

enter image description here

Now, title here donot have operator, 'Contains' which is required to filter matching titles.

enter image description here

I am using Global Populate filter as exposed filter. I tried using hook_views_query_alter which donot work with index view of search api. How should we do this?

0

I used hook_search_api_views_query_alter from search_api_views.api.php.

function MYMODULE_search_api_views_query_alter(&$view, &$query) {
  // Altering the title filter to operator LIKE which is not available in the 
  // views itself.
  if ($view->name = '[VIEWNAME]') {
    if (!empty($query->where[1]['conditions'][0][1])) {
      $query->where[1]['conditions'][0][1] = '%' . $query->where[1]['conditions'][0][1] . '%';
      $query->where[1]['conditions'][0][2] = 'LIKE';
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.