protected function SearchApiElasticsearchConnector::handleFulltextSearch in Elasticsearch Connector 7.5
Same name and namespace in other branches
- 7 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::handleFulltextSearch()
- 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::handleFulltextSearch()
Helper function. Handle freetext search parameters.
Parameters
SearchApiQueryInterface $query:
Return value
array Return the query parameters required for elasticsearch.
1 call to SearchApiElasticsearchConnector::handleFulltextSearch()
- SearchApiElasticsearchConnector::getSearchQueryOptions in modules/
elasticsearch_connector_search_api/ service.inc - Helper function return associative array with query options.
File
- modules/
elasticsearch_connector_search_api/ service.inc, line 1582 - Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.
Class
- SearchApiElasticsearchConnector
- Search service class.
Code
protected function handleFulltextSearch(SearchApiQueryInterface $query, $index_fields) {
$bool_query = array();
$wildcardQuery = $this
->handleWildcardQuery($query, $index_fields);
if (!empty($wildcardQuery)) {
$bool_query['bool']['should'][] = $wildcardQuery;
}
$multyMatch = $this
->handleMultyMatchQuery($query, $index_fields);
// If prefix enabled execute the prefix query.
$prefixMatch = array();
if ($query
->getOption(self::PREFIX_SEARCH, FALSE) && !$this
->isWildcardQuery($query)) {
$prefixMatch = $this
->handlePrefixQuery($query, $index_fields);
}
if (!empty($multyMatch) && $this
->isWildcardQuery($query)) {
$bool_query['bool']['should'][] = $multyMatch;
}
elseif (!empty($multyMatch) && !$this
->isWildcardQuery($query) && !empty($prefixMatch)) {
$bool_query['bool']['should'][] = $prefixMatch;
$bool_query['bool']['should'][] = $multyMatch;
}
elseif (!empty($multyMatch) && !$this
->isWildcardQuery($query)) {
$bool_query['bool']['must'][] = $multyMatch;
}
$mlt_query = $this
->handleMLTSearch($query, $index_fields);
//var_dump($mlt_query);exit;
if (!empty($mlt_query)) {
$bool_query['bool']['should'][] = $mlt_query;
}
$stringQuery = $this
->handleStringQuery($query, $index_fields);
if (!empty($stringQuery)) {
$bool_query['bool']['should'][] = $stringQuery;
}
return $bool_query;
}