protected function translateQueries(CriteriaList $criteria_list) { if ($criteria_list->isEmpty()) { return ['match_all' => []]; } else { // @todo atm we only support global search on the _all field // more complex search query building will follow up $search_criteria = $criteria_list->getFirst(); if (!$search_criteria instanceof SearchCriteria) { throw new RuntimeError(sprintf('Only instances of %s supported as search-criteria.', SearchCriteria::CLASS)); } $phrase = $search_criteria->getPhrase(); if (preg_match('~^suggest:([\\.\\w]+)=(.+)~', $phrase, $matches)) { $suggest_field_parts = []; // strip the 'type' portion of the attribute-path, to address props the way ES expects foreach (explode('.', $matches[1]) as $i => $field_part) { if ($i % 2 === 0) { $suggest_field_parts[] = $field_part; } } $suggest_field = implode('.', $suggest_field_parts); $suggest_field .= '.suggest'; // convention: multi field for suggestions $suggest_term = $matches[2]; return ['match_phrase_prefix' => [$suggest_field => ['query' => $suggest_term, 'max_expansions' => 15]]]; } else { return $this->buildSearchQuery($search_criteria); } } }