Update AdvancedSearchQuery.php
Add missing boost number for each field for edismax search
This commit is contained in:
parent
ec0922fa78
commit
9d34cf708b
1 changed files with 18 additions and 3 deletions
|
|
@ -250,10 +250,25 @@ class AdvancedSearchQuery {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$query_fields = $fields_list;
|
$query_fields = $fields_list;
|
||||||
|
|
||||||
}
|
}
|
||||||
$query_fields = implode(" ", array_unique($query_fields));
|
|
||||||
$dismax->setQueryFields($query_fields);
|
// Get the indexed fields from /admin/config/search/search-api/index/..../fields
|
||||||
|
$boostedFields = [];
|
||||||
|
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) {
|
||||||
|
foreach($boostedFields as $indexed_field => $boostnum) {
|
||||||
|
if(strpos($str_fields_with_boost, $indexed_field) == false && strpos($solr_field, $indexed_field) !== false) {
|
||||||
|
$str_fields_with_boost .= $solr_field . "^" . $boostnum . " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dismax->setQueryFields($str_fields_with_boost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue