Smile\ElasticsuiteThesaurus\Model\Index::getSynonymRewrites PHP Метод

getSynonymRewrites() приватный Метод

Generates all possible synonym rewrites for a store and text query.
private getSynonymRewrites ( integer $storeId, string $queryText, string $type ) : array
$storeId integer Store id.
$queryText string Text query.
$type string Substitution type (synonym or expansion).
Результат array
    private function getSynonymRewrites($storeId, $queryText, $type)
    {
        $indexName = $this->getIndexAlias($storeId);
        $analysis = $this->client->indices()->analyze(['index' => $indexName, 'text' => $queryText, 'analyzer' => $type]);
        $synonymByPositions = [];
        foreach ($analysis['tokens'] as $token) {
            if ($token['type'] == 'SYNONYM') {
                $positionKey = sprintf('%s_%s', $token['start_offset'], $token['end_offset']);
                $synonymByPositions[$positionKey][] = $token;
            }
        }
        return $this->combineSynonyms($queryText, $synonymByPositions);
    }