diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/LuceneSyntaxHelper.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/LuceneSyntaxHelper.php index 34b7c6598b143ff511ed48e22373ac6f88196bd7..dc16a17a5489bbc722e888ccbd283d7b6a96ad40 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/LuceneSyntaxHelper.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/LuceneSyntaxHelper.php @@ -437,7 +437,20 @@ class LuceneSyntaxHelper 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. * @@ -483,6 +496,7 @@ class LuceneSyntaxHelper $input = $this->normalizeBoosts($input); $input = $this->normalizeBracesAndBrackets($input); $input = $this->normalizeUnquotedText($input); + $input = $this->normalizeColons($input); // Remove surrounding slashes and whitespace -- these serve no purpose // and can cause problems. diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php index 02734b91e728d20cb546741f9a16c60b82ffe13a..381b9bb804def44ad7eeb48d78c1f2324face000 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php @@ -367,9 +367,6 @@ class QueryBuilder implements QueryBuilderInterface 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 // apply it to other fields through our defined handlers, so we'll leave // it as-is: @@ -377,11 +374,6 @@ class QueryBuilder implements QueryBuilderInterface 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 // intend to use the question mark as a wildcard -- let's account for that // possibility