Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Spellchecker::parseTermVectors PHP Method

parseTermVectors() private method

Result is an array containing : - total : number of terms into the query - stop : number of stopwords into the query - exact : number of terms correctly spelled into the query - missing : number of terms of the query not found into the index - standard : number of terms of the query found using the standard analyzer.
private parseTermVectors ( array $termVectors, integer $cutoffFrequencyLimit ) : array
$termVectors array The term vector query response.
$cutoffFrequencyLimit integer Cutoff freq (max absolute number of docs to consider term as a stopword).
return array
    private function parseTermVectors($termVectors, $cutoffFrequencyLimit)
    {
        $queryTermStats = ['stop' => 0, 'exact' => 0, 'standard' => 0, 'missing' => 0];
        $statByPosition = $this->extractTermStatsByPoisition($termVectors);
        foreach ($statByPosition as $positionStat) {
            $type = 'missing';
            if ($positionStat['doc_freq'] > 0) {
                $type = 'standard';
                if ($positionStat['doc_freq'] >= $cutoffFrequencyLimit) {
                    $type = 'stop';
                } elseif (in_array(FieldInterface::ANALYZER_WHITESPACE, $positionStat['analyzers'])) {
                    $type = 'exact';
                }
            }
            $queryTermStats[$type]++;
        }
        $queryTermStats['total'] = count($statByPosition);
        return $queryTermStats;
    }