protected function SearchApiElasticsearchConnector::handleWildcardQuery in Elasticsearch Connector 7
Same name and namespace in other branches
- 7.5 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::handleWildcardQuery()
- 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::handleWildcardQuery()
Helper function. Handle wildcard query.
Parameters
SearchApiQueryInterface $query:
Return value
array Return the should cuase for the Elasticsearch query.
1 call to SearchApiElasticsearchConnector::handleWildcardQuery()
- 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 1331 - Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.
Class
- SearchApiElasticsearchConnector
- Search service class.
Code
protected function handleWildcardQuery(SearchApiQueryInterface $query, $index_fields) {
$originalKeys = $query
->getOriginalKeys();
$wildcard_query = array();
if (!empty($originalKeys) && preg_match('/\\*|\\?/', $originalKeys)) {
$query_full_text_fields = $query
->getFields();
foreach ($query_full_text_fields as $fulltext_field) {
$boost = isset($index_fields[$fulltext_field]['boost']) ? '^' . $index_fields[$fulltext_field]['boost'] : '';
$field_values = array(
'value' => strtolower($originalKeys),
);
if (isset($index_fields[$fulltext_field]['boost'])) {
$field_values['boost'] = $index_fields[$fulltext_field]['boost'];
}
$wildcard_query[] = array(
'wildcard' => array(
$fulltext_field => $field_values,
),
);
}
}
return $wildcard_query;
}