Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
fix parse text with numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
himiklab committed Nov 7, 2016
1 parent 9a053fb commit 12cc30e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
use yii\helpers\FileHelper;
use ZendSearch\Lucene\Analysis\Analyzer\Analyzer;
use ZendSearch\Lucene\Analysis\Analyzer\Common\Utf8;
use ZendSearch\Lucene\Analysis\Analyzer\Common\Utf8Num;
use ZendSearch\Lucene\Analysis\Analyzer\Common\Utf8\CaseInsensitive;
use ZendSearch\Lucene\Analysis\Analyzer\Common\Utf8Num\CaseInsensitive as CaseInsensitiveNum;
use ZendSearch\Lucene\Document;
use ZendSearch\Lucene\Document\Field;
use ZendSearch\Lucene\Index\Term as IndexTerm;
Expand All @@ -38,7 +40,7 @@ class Search extends Component
/** @var string alias or directory path */
public $indexDirectory = '@app/runtime/search';

/** @var bool */
/** @var boolean */
public $caseSensitivity = false;

/** @var int Minimum term prefix length (number of minimum non-wildcard characters) */
Expand All @@ -47,6 +49,9 @@ class Search extends Component
/** @var int 0 means no limit */
public $resultsLimit = 0;

/** @var boolean */
public $parseNumeric = false;

/** @var \ZendSearch\Lucene\Index */
protected $luceneIndex;

Expand All @@ -59,9 +64,9 @@ public function init()
{
QueryParser::setDefaultEncoding('UTF-8');
if ($this->caseSensitivity) {
Analyzer::setDefault(new Utf8());
Analyzer::setDefault($this->parseNumeric ? new Utf8Num() : new Utf8());
} else {
Analyzer::setDefault(new CaseInsensitive());
Analyzer::setDefault($this->parseNumeric ? new CaseInsensitiveNum() : new CaseInsensitive());
}

$this->indexDirectory = FileHelper::normalizePath(Yii::getAlias($this->indexDirectory));
Expand Down

0 comments on commit 12cc30e

Please sign in to comment.