Skip to content

Commit

Permalink
Merge pull request #566 from afoucret/fix-termvectors
Browse files Browse the repository at this point in the history
Fix term vectors on empty indices.
  • Loading branch information
afoucret authored Oct 17, 2017
2 parents ffb8af8 + e1b5721 commit 56a29a7
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,24 @@ public function getSpellingType(RequestInterface $request)
*/
private function loadSpellingType(RequestInterface $request)
{
$cutoffFrequencyLimit = $this->getCutoffrequencyLimit($request);
$termVectors = $this->getTermVectors($request);
$queryTermStats = $this->parseTermVectors($termVectors, $cutoffFrequencyLimit);

$spellingType = self::SPELLING_TYPE_FUZZY;

if ($queryTermStats['total'] == $queryTermStats['stop']) {
$spellingType = self::SPELLING_TYPE_PURE_STOPWORDS;
} elseif ($queryTermStats['total'] == $queryTermStats['stop'] + $queryTermStats['exact']) {
$spellingType = self::SPELLING_TYPE_EXACT;
} elseif ($queryTermStats['missing'] == 0) {
$spellingType = self::SPELLING_TYPE_MOST_EXACT;
} elseif ($queryTermStats['total'] - $queryTermStats['missing'] > 0) {
$spellingType = self::SPELLING_TYPE_MOST_FUZZY;
try {
$cutoffFrequencyLimit = $this->getCutoffrequencyLimit($request);
$termVectors = $this->getTermVectors($request);
$queryTermStats = $this->parseTermVectors($termVectors, $cutoffFrequencyLimit);

if ($queryTermStats['total'] == $queryTermStats['stop']) {
$spellingType = self::SPELLING_TYPE_PURE_STOPWORDS;
} elseif ($queryTermStats['total'] == $queryTermStats['stop'] + $queryTermStats['exact']) {
$spellingType = self::SPELLING_TYPE_EXACT;
} elseif ($queryTermStats['missing'] == 0) {
$spellingType = self::SPELLING_TYPE_MOST_EXACT;
} elseif ($queryTermStats['total'] - $queryTermStats['missing'] > 0) {
$spellingType = self::SPELLING_TYPE_MOST_FUZZY;
}
} catch (\Exception $e) {
;
}

return $spellingType;
Expand Down

0 comments on commit 56a29a7

Please sign in to comment.