private function extractTermStatsByPoisition($termVectors)
    {
        $statByPosition = [];
        $analyzers      = [FieldInterface::ANALYZER_STANDARD, FieldInterface::ANALYZER_WHITESPACE];

        foreach ($termVectors['term_vectors'] as $propertyName => $fieldData) {
            $analyzer = $this->getAnalyzer($propertyName);
            if (in_array($analyzer, $analyzers)) {
                foreach ($fieldData['terms'] as $term => $termStats) {
                    foreach ($termStats['tokens'] as $token) {
                        $positionKey = $token['position'];

                        if (!isset($termStats['doc_freq'])) {
                            $termStats['doc_freq'] = 0;
                        }

                        if (!isset($statByPosition[$positionKey])) {
                            $statByPosition[$positionKey]['term']     = $term;
                            $statByPosition[$positionKey]['doc_freq'] = $termStats['doc_freq'];
                        }

                        if ($termStats['doc_freq']) {
                            $statByPosition[$positionKey]['analyzers'][] = $analyzer;
                        }

                        $statByPosition[$positionKey]['doc_freq'] = max(
                            $termStats['doc_freq'],
                            $statByPosition[$positionKey]['doc_freq']
                        );
                    }
                }
            }
        }

        return $statByPosition;
    }
private function extractTermStatsByPoisition($termVectors)
    {
        $statByPosition = [];
        $analyzers      = [FieldInterface::ANALYZER_STANDARD, FieldInterface::ANALYZER_WHITESPACE];

        foreach ($termVectors['term_vectors'] as $propertyName => $fieldData) {
            $analyzer = $this->getAnalyzer($propertyName);
            if (in_array($analyzer, $analyzers)) {
                foreach ($fieldData['terms'] as $term => $termStats) {
                    foreach ($termStats['tokens'] as $token) {
                        $positionKey = $token['position'];

                        if (!isset($termStats['doc_freq'])) {
                            $termStats['doc_freq'] = 0;
                        }

                        if (!isset($statByPosition[$positionKey])) {
                            $statByPosition[$positionKey]['term']     = $term;
                            $statByPosition[$positionKey]['doc_freq'] = $termStats['doc_freq'];
                        }

                        if ($termStats['doc_freq']) {
                            $statByPosition[$positionKey]['analyzers'][] = $analyzer;
                        }

                        $statByPosition[$positionKey]['doc_freq'] = max(
                            $termStats['doc_freq'],
                            $statByPosition[$positionKey]['doc_freq']
                        );
                    }
                }
            }
        }

        return $statByPosition;
    }
private function extractTermStatsByPoisition ( $ termVectors ) { $ statByPosition = [ ] ; $ analyzers = [ FieldInterface :: ANALYZER_STANDARD , FieldInterface :: ANALYZER_WHITESPACE ] ; foreach ( $ termVectors [ 'term_vectors' ] as $ propertyName => $ fieldData ) { $ analyzer = $ this -> getAnalyzer ( $ propertyName ) ; if ( in_array ( $ analyzer , $ analyzers ) ) { foreach ( $ fieldData [ 'terms' ] as $ term => $ termStats ) { foreach ( $ termStats [ 'tokens' ] as $ token ) { $ positionKey = $ token [ 'position' ] ; if ( ! isset ( $ termStats [ 'doc_freq' ] ) ) { $ termStats [ 'doc_freq' ] = 0 ; } if ( ! isset ( $ statByPosition [ $ positionKey ] ) ) { $ statByPosition [ $ positionKey ] [ 'term' ] = $ term ; $ statByPosition [ $ positionKey ] [ 'doc_freq' ] = $ termStats [ 'doc_freq' ] ; } if ( $ termStats [ 'doc_freq' ] ) { $ statByPosition [ $ positionKey ] [ 'analyzers' ] [ ] = $ analyzer ; } $ statByPosition [ $ positionKey ] [ 'doc_freq' ] = max ( $ termStats [ 'doc_freq' ] , $ statByPosition [ $ positionKey ] [ 'doc_freq' ] ) ; } } } } return $ statByPosition ; }
Extract term stats by position from a term vectors query response.
Wil return an array of doc_freq, analayzers and term by position.

@param array $termVectors The term vector query response.

@return array
Extract term stats by position from a term vectors query response . Wil return an array of doc_freq analayzers and term by position .