Skip to content
Snippets Groups Projects
Commit 8abae60b authored by Demian Katz's avatar Demian Katz
Browse files

Query builder cleanup.

- Moved colon processing to more logical location
- Removed unreachable range generation code
parent 28e0085f
Branches
Tags
No related merge requests found
...@@ -437,7 +437,20 @@ class LuceneSyntaxHelper ...@@ -437,7 +437,20 @@ class LuceneSyntaxHelper
return $input; return $input;
} }
/**
* Normalize field specifications within the query.
*
* @param string $input String to normalize
*
* @return string
*/
protected function normalizeColons($input)
{
$input = preg_replace('/:+/', ':', $input);
$input = preg_replace('/(\:[:\s]+|[:\s]+:)/', ' ', $input);
return $input == ':' ? '' : $input;
}
/** /**
* Prepare input to be used in a SOLR query. * Prepare input to be used in a SOLR query.
* *
...@@ -483,6 +496,7 @@ class LuceneSyntaxHelper ...@@ -483,6 +496,7 @@ class LuceneSyntaxHelper
$input = $this->normalizeBoosts($input); $input = $this->normalizeBoosts($input);
$input = $this->normalizeBracesAndBrackets($input); $input = $this->normalizeBracesAndBrackets($input);
$input = $this->normalizeUnquotedText($input); $input = $this->normalizeUnquotedText($input);
$input = $this->normalizeColons($input);
// Remove surrounding slashes and whitespace -- these serve no purpose // Remove surrounding slashes and whitespace -- these serve no purpose
// and can cause problems. // and can cause problems.
......
...@@ -367,9 +367,6 @@ class QueryBuilder implements QueryBuilderInterface ...@@ -367,9 +367,6 @@ class QueryBuilder implements QueryBuilderInterface
return $handler->getFilterQuery(); return $handler->getFilterQuery();
} }
// Strip out any colons that are NOT part of a field specification:
$string = preg_replace('/(\:\s+|\s+:)/', ' ', $string);
// If the query already includes field specifications, we can't easily // If the query already includes field specifications, we can't easily
// apply it to other fields through our defined handlers, so we'll leave // apply it to other fields through our defined handlers, so we'll leave
// it as-is: // it as-is:
...@@ -377,11 +374,6 @@ class QueryBuilder implements QueryBuilderInterface ...@@ -377,11 +374,6 @@ class QueryBuilder implements QueryBuilderInterface
return $string; return $string;
} }
// Convert empty queries to return all values in a field:
if (empty($string)) {
$string = '[* TO *]';
}
// If the query ends in a non-escaped question mark, the user may not really // If the query ends in a non-escaped question mark, the user may not really
// intend to use the question mark as a wildcard -- let's account for that // intend to use the question mark as a wildcard -- let's account for that
// possibility // possibility
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment