private function getSynonymRewrites($storeId, $queryText, $type, $maxRewrites)
    {
        $indexName = $this->getIndexAlias($storeId);

        try {
            $analysis = $this->client->analyze(
                ['index' => $indexName, 'body' => ['text' => $queryText, 'analyzer' => $type]]
            );
        } catch (\Exception $e) {
            $analysis = ['tokens' => []];
        }

        $synonymByPositions = [];

        foreach ($analysis['tokens'] ?? [] as $token) {
            if ($token['type'] == 'SYNONYM') {
                $positionKey = sprintf('%s_%s', $token['start_offset'], $token['end_offset']);
                $token['token'] = str_replace('_', ' ', $token['token']);
                $synonymByPositions[$positionKey][] = $token;
            }
        }

        return $this->combineSynonyms($queryText, $synonymByPositions, $maxRewrites);
    }