I am trying to perform a search programmatically with our database search api (no solr or other servers) with the following code:
$query = \Drupal\search_api\Entity\Index::load('us_search')->query(); $query->keys($search_entry); $query->setFulltextFields(['title', 'url']); $query->range(0, 5); $result = $query->execute();
However, when I run the code it is throwing this error:
Search keys are given but no fulltext fields are defined.
I further check if the index itself was able to pull the fulltext fields using this code but the array is always empty
$index = \Drupal\search_api\Entity\Index::load('us_content'); $index_fields = $index->getFulltextFields();
The fields are setup correctly and the search works perfectly fine on the UI side. It is just that I need to be able to create the search programatically for a web service but am stuck right now due to this error.
Anyone has any idea what might be missing? Thanks