Skip to content

Instantly share code, notes, and snippets.

@sonnykt
Created October 8, 2025 05:18
Show Gist options
  • Select an option

  • Save sonnykt/0de35de33a37f17352468a1860fa6603 to your computer and use it in GitHub Desktop.

Select an option

Save sonnykt/0de35de33a37f17352468a1860fa6603 to your computer and use it in GitHub Desktop.
Drupal - Debug Search API Solr search
$index = \Drupal\search_api\Entity\Index::load('solr_index');
$query = $index->query();
$parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')->createInstance('direct');
$query->setParseMode($parse_mode);
$query->keys('keywords to search');
$results = $query->execute();
$items = $results->getResultItems();
= [
    "entity:node/885:en" => Drupal\search_api\Item\Item {#8557},
    "entity:node/688:en" => Drupal\search_api\Item\Item {#8566},
    ...
  ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment