new version with ajax
This commit is contained in:
parent
27c044f040
commit
a0b1c7785e
8 changed files with 415 additions and 128 deletions
68
conjuction_parantheses_correction.patch
Normal file
68
conjuction_parantheses_correction.patch
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
diff --git a/src/AdvancedSearchQuery.php b/src/AdvancedSearchQuery.php
|
||||
index af40fb7..b8c6eb7 100644
|
||||
--- a/src/AdvancedSearchQuery.php
|
||||
+++ b/src/AdvancedSearchQuery.php
|
||||
@@ -143,6 +143,7 @@ class AdvancedSearchQuery {
|
||||
public function alterQuery(Request $request, SolariumQueryInterface &$solarium_query, DrupalQueryInterface $search_api_query) {
|
||||
// Only apply if a Advanced Search Query was made.
|
||||
$terms = $this->getTerms($request);
|
||||
+
|
||||
if (!empty($terms)) {
|
||||
$index = $search_api_query->getIndex();
|
||||
/** @var \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend $backend */
|
||||
@@ -163,11 +164,10 @@ class AdvancedSearchQuery {
|
||||
|
||||
if (!$isDismax) {
|
||||
// To support negative queries we must first bring in all documents.
|
||||
- $q[] = $this->negativeQuery($terms) ? "*:*" : "";
|
||||
+ $q = $this->negativeQuery($terms) ? "*:*" : "";
|
||||
}
|
||||
-
|
||||
$term = array_shift($terms);
|
||||
- $q[] = $term->toSolrQuery($field_mapping);
|
||||
+ $q = '(' . trim($term->toSolrQuery($field_mapping));
|
||||
|
||||
// New.
|
||||
$fields_list[] = $term->toSolrFields($field_mapping);
|
||||
@@ -180,8 +180,8 @@ class AdvancedSearchQuery {
|
||||
|
||||
// For multiple conditions.
|
||||
foreach ($terms as $term) {
|
||||
- $q[] = $term->getConjunction();
|
||||
- $q[] = $term->toSolrQuery($field_mapping);
|
||||
+ $q .= ')' . $term->getConjunction() . '(';
|
||||
+ $q .= trim($term->toSolrQuery($field_mapping));
|
||||
|
||||
// New.
|
||||
$fields_list[] = $term->toSolrFields($field_mapping);
|
||||
@@ -193,8 +193,8 @@ class AdvancedSearchQuery {
|
||||
}
|
||||
|
||||
}
|
||||
- $q = implode(' ', $q);
|
||||
|
||||
+ $q .= ')';
|
||||
// Limit extra processing if Luncene Search is enable.
|
||||
if ($isDismax) {
|
||||
|
||||
@@ -257,7 +257,7 @@ class AdvancedSearchQuery {
|
||||
foreach ($index->getFields() as $field_id => $field) {
|
||||
$boostedFields[$field_id] = $field->getBoost();
|
||||
}
|
||||
-
|
||||
+
|
||||
$str_fields_with_boost = "";
|
||||
// Adding a boost number for each field)
|
||||
foreach($query_fields as $solr_field) {
|
||||
@@ -291,11 +291,9 @@ class AdvancedSearchQuery {
|
||||
// make this field non-empty.
|
||||
//$search_api_query->keys("advanced search");
|
||||
}
|
||||
-
|
||||
$solarium_query->setQuery($q);
|
||||
}
|
||||
}
|
||||
-
|
||||
/**
|
||||
* Alters the given view to be recursive if applicable.
|
||||
*
|
||||
Loading…
Add table
Add a link
Reference in a new issue