protected function SearchApiElasticsearchConnector::handlePrefixQuery in Elasticsearch Connector 7
Same name and namespace in other branches
- 7.5 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::handlePrefixQuery()
- 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::handlePrefixQuery()
Parameters
SearchApiQueryInterface $query:
array $index_fields:
Return value
array The query to be used in final query structure.
1 call to SearchApiElasticsearchConnector::handlePrefixQuery()
- SearchApiElasticsearchConnector::handleFulltextSearch in modules/
elasticsearch_connector_search_api/ service.inc - Helper function. Handle freetext search parameters.
File
- modules/
elasticsearch_connector_search_api/ service.inc, line 1379 - Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.
Class
- SearchApiElasticsearchConnector
- Search service class.
Code
protected function handlePrefixQuery(SearchApiQueryInterface $query, $index_fields) {
$originalKeys = $query
->getOriginalKeys();
$prefix_query = array();
if (!empty($originalKeys)) {
$query_full_text_fields = $this
->handlePrefixQueryFields($query);
foreach ($query_full_text_fields as $fulltext_field) {
$boost = isset($index_fields[$fulltext_field]['boost']) ? '^' . $index_fields[$fulltext_field]['boost'] : '';
$field_values = array(
'prefix' => strtolower($originalKeys),
);
if (isset($index_fields[$fulltext_field]['boost'])) {
$field_values['boost'] = $index_fields[$fulltext_field]['boost'];
}
$prefix_query[] = array(
'prefix' => array(
$fulltext_field => $field_values,
),
);
}
}
return $prefix_query;
}