diff --git a/search2/search/SearchCommandLexer.php b/search2/search/SearchCommandLexer.php index 1780084..fa0d329 100755 --- a/search2/search/SearchCommandLexer.php +++ b/search2/search/SearchCommandLexer.php @@ -95,6 +95,9 @@ class SearchCommandLexer $append=false; $clear=true; break; + case '~': + $this->token=SearchCommandParser::TILDE; + break; case '=': $this->token=SearchCommandParser::IS; break; @@ -136,8 +139,8 @@ class SearchCommandLexer } elseif ($this->lookahead == '=') { - $this->zap(); $this->token=($this->char == '<')?(SearchCommandParser::LE):(SearchCommandParser::GE); + $this->zap(); } else { @@ -223,6 +226,9 @@ class SearchCommandLexer { switch($this->char) { + case '"': + $this->value .= '"'; + break; case 'r': $this->value .= "\r"; break; diff --git a/search2/search/expr.inc.php b/search2/search/expr.inc.php index bccf485..4674a15 100755 --- a/search2/search/expr.inc.php +++ b/search2/search/expr.inc.php @@ -390,13 +390,14 @@ class FieldExpr extends Expr $value = $right; } - if (substr($value,0,1) != '\'' || substr($value,-1) != '\'') + if ((substr($value,0,1) == '\'' && substr($value,-1) == '\'') || (substr($value,0,1) == '"' && substr($value,-1) == '"')) { - OpExpr::rewriteString($left, $op, $right, $not); + $value = trim( substr($value,1,-1) ); + $right = new ValueExpr($value); } else { - $right = new ValueExpr(trim(substr($value,1,-1))); + OpExpr::rewriteString($left, $op, $right, $not); } } } @@ -541,19 +542,26 @@ class ValueExpr extends Expr */ protected $value; + protected $fuzzy; + + protected $proximity; + /** * Constructor for the value expression * * @param mixed $value */ - public function __construct($value) + public function __construct($value, $fuzzy=null, $proximity=null) { parent::__construct(); $this->value=$value; + $this->fuzzy = $fuzzy; + $this->proximity = $proximity; } public function getValue() { + return $this->value; } @@ -851,7 +859,14 @@ class TextQueryBuilder implements QueryBuilder $not = $expr->not()?' NOT ':''; - $query = "$not$fieldname: \"$value\""; + if (strpos($value, ' ') === false) + { + $query = "$not$fieldname: $value"; + } + else + { + $query = "$not$fieldname: \"$value\""; + } } return $query; @@ -875,7 +890,10 @@ class TextQueryBuilder implements QueryBuilder $not = $expr->not()?' NOT ':''; - $query .= "$not$fieldname: \"$value\""; + if (strpos($value, ' ') !== false) + $query .= "$not$fieldname: \"$value\""; + else + $query .= "$not$fieldname: $value"; } return $query; @@ -1931,7 +1949,8 @@ class OpExpr extends Expr $results = array(); - if ($this->debug) print "\n\n$sql\n\n"; + global $default; + $default->log->debug("SEARCH SQL: $sql"); $rs = DBUtil::getResultArray($sql); if (PEAR::isError($rs)) @@ -1969,7 +1988,9 @@ class OpExpr extends Expr } $indexer = Indexer::get(); - if ($this->debug) print "\n\n$query\n\n"; + global $default; + $default->log->debug("SEARCH LUCENE: $query"); + $results = $indexer->query($query); foreach($results as $item) {