I'm trying to alter a query with hook_search_api_query_alter
I'd created a view without any filter becouse i want to send filters programmatically.
everything with all the fields other than search_api_views_fulltext, when I try to send values I take "Filter term on unknown or unindexed field search_api_views_fulltext" I take the values of filters from node.
The code
function xxxx_search_api_query_alter(SearchApiQueryInterface $query) {
$node = menu_get_object();
// Check we're on a 'full' node page.
if ($node && isset($node->nid)) {
// Check the node is of the right type
if ($node->type != 'xxxx') {
return;
}
else {
$info = $query->getIndex();
dpm($info);
$query->createFilter('AND');
$query->condition('field_generi', $node->field_generi['und'][0]['tid'], '=');
$query->condition('field_fonti', $node->field_fonti['und'][0]['tid'], '=');
$query->condition('search_api_views_fulltext', $node->field_ricerca_libero['und'][0]['value'], '=');
}
what I'm doing wrong?
Comments
Comment #1
romanciuc commentedmaybe found it. i use now
$query->keys()
and it's work for me
Comment #2
romanciuc commented