protected function SearchApiElasticsearchConnector::handleMultyMatchQuery in Elasticsearch Connector 7.5
Same name and namespace in other branches
- 7 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::handleMultyMatchQuery()
- 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::handleMultyMatchQuery()
Handle the multy match query.
Parameters
SearchApiQueryInterface $query:
array $index_fields:
Return value
array The query to be used in final query structure.
1 call to SearchApiElasticsearchConnector::handleMultyMatchQuery()
- 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 1492 - Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.
Class
- SearchApiElasticsearchConnector
- Search service class.
Code
protected function handleMultyMatchQuery(SearchApiQueryInterface $query, $index_fields) {
$originalKeys = $query
->getOriginalKeys();
$multymatch_query = array();
if (!empty($originalKeys)) {
$query_full_text_fields = $query
->getFields();
$fields = array();
foreach ($query_full_text_fields as $fulltext_field) {
$boost = isset($index_fields[$fulltext_field]['boost']) ? '^' . $index_fields[$fulltext_field]['boost'] : '';
$fields[] = $fulltext_field . $boost;
}
$multymatch_query = array(
'multi_match' => array(
'query' => $originalKeys,
'fields' => $fields,
),
);
$keys = $query
->getKeys();
if (isset($keys['#conjunction']) && $keys['#conjunction'] == 'AND') {
$multymatch_query['multi_match']['operator'] = 'AND';
$multymatch_query['multi_match']['type'] = 'cross_fields';
}
}
return $multymatch_query;
}