Score:0

Ss it possible to add alter query to add an "OR" operator condition to Search API alter that actually expands the results?

ng flag

We need to alter a Search API query using hook_search_api_query_alter() to add an additional condition OR condition that is "any of the previous condition OR this new condition"

Example: We want to show nodes whose State field is Florida or the Location Type field is "National".

Doing something like the below continues to narrow the results instead of expanding them as Florida is already set in the View query and the alter code below now narrows the results to State=FL AND Type=National instead of State=FL OR Type=National

 $parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')->createInstance('direct');
  $parse_mode->setConjunction('OR');
  $query->setParseMode($parse_mode);
  $conditions = $query->createConditionGroup('OR');
  $conditions->addCondition('field_resource_location_type', 'national', 'IN');
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.