Skip to main content
1 of 2

search API: \Drupal\search_api\Entity\Index::load('INDEX_ID'); returns null

I am trying to create a module that executes a search -- I tried to utilize the documentation for calling a search in code but

$index = \Drupal\search_api\Entity\Index::load('INDEX_ID');

gives me $index == NULL so the very second line

$query = $index->query();

blows it up. I tried replacing 'INDEX_ID' with 'default_index' but that didn't help. Search API is definitely enabled. Any idea why \Drupal\search_api\Entity\Index::load would keep giving me NULL?