public function SearchApiCommands::search in Search API 8
Searches for a keyword or phrase in a given index.
@command search-api:search
@usage drush search-api:search node_index title Search for "title" inside the "node_index" index. @usage drush sapi-search node_index title Alias to search for "title" inside the "node_index" index.
@field-labels id: ID label: Label
@aliases sapi-search,search-api-search
Parameters
string $indexId: The machine name of an index.
string $keyword: The keyword to look for.
Return value
\Consolidation\OutputFormatters\StructuredData\RowsOfFields The table rows.
Throws
\Drupal\search_api\SearchApiException Thrown if no search query could be created for the given index, for example because it is disabled or its server could not be loaded.
\Drupal\search_api\ConsoleException Thrown if searching failed for any reason.
File
- src/
Commands/ SearchApiCommands.php, line 360
Class
- SearchApiCommands
- Defines Drush commands for the Search API.
Namespace
Drupal\search_api\CommandsCode
public function search($indexId, $keyword) {
$rows = $this->commandHelper
->searchIndexCommand($indexId, $keyword);
return new RowsOfFields($rows);
}