Merge pull request #26 from amym-li/contrib

Searching using 'is not' when EDismax is enabled always returns no results
This commit is contained in:
Kyle Huynh 2023-03-14 16:38:20 -04:00 committed by GitHub
commit 599fc81e39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -160,9 +160,11 @@ class AdvancedSearchQuery {
$isSearchAllFields = false;
$fields_list = [];
if (!$isDismax) {
// To support negative queries we must first bring in all documents.
$q[] = $this->negativeQuery($terms) ? "*:*" : "";
}
$term = array_shift($terms);
$q[] = $term->toSolrQuery($field_mapping);

View file

@ -302,7 +302,8 @@ class AdvancedSearchQueryTerm {
return $value;
}
else {
return "(" .$value . " OR " . str_replace('"', "", trim($value)) . ")";
$isNot = $this->getInclude() ? "" : "!";
return $isNot . "(" .$value . " OR " . str_replace('"', "", trim($value)) . ")";
}
}
if (!$this->getInclude()) {