Wednesday 13 July 2016

How to get Search API DB results?

We can use search_api_query function to get the results by passing index machine name and search key word as follows:
$index = 'nodes_index';
$keyword = 'learn subjects';
$query = search_api_query($index);
$query->keys($keyword);
$query->range(0,4);
$results = $query->execute();

No comments:

Post a Comment

Your comment is so valuable as it would help me in my growth of knowledge.