better search with filters

This commit is contained in:
Bachir Soussi Chiadmi 2021-10-27 15:51:14 +02:00
parent c5fe8c0c92
commit 20fea9dce1
1 changed files with 33 additions and 22 deletions

View File

@ -73,19 +73,19 @@ class Base extends ControllerBase {
// $this->or_query->setOption('termid', $this->term);
}
$fulltextFields = [];
if ($this->filters) {
// FILTERS
$filters_conditions = $this->and_query->createConditionGroup('AND');
foreach ($this->filters as $filter) {
$filter = (int) $filter;
foreach (['tag_tid', 'thesaurus_tid'] as $field) {
foreach (['thesaurus_tid'] as $field) { // 'tag_tid',
$filters_conditions->addCondition($field, $filter);
}
}
$this->and_query->addConditionGroup($filters_conditions);
}else{
}
// else{
$fulltextFields = [];
// Recherche uniquement sur les champ thésaurus et tag
$fulltextFields += [
'thesaurus_name_0',
@ -103,11 +103,10 @@ class Base extends ControllerBase {
'tag_name',
'tag_synonyms'
];
}
if(count($fulltextFields)){
$this->and_query->setFulltextFields($fulltextFields);
}
// }
// Restrict the search to specific languages.
$this->and_query->setLanguages([$lang]);
@ -171,6 +170,18 @@ class Base extends ControllerBase {
$this->or_query->addConditionGroup($ref_conditions);
}
if ($this->filters) {
// FILTERS
$or_filters_conditions = $this->or_query->createConditionGroup('OR');
foreach ($this->filters as $filter) {
$filter = (int) $filter;
foreach (['thesaurus_tid'] as $field) { // 'tag_tid',
$or_filters_conditions->addCondition($field, $filter);
}
}
$this->or_query->addConditionGroup($or_filters_conditions);
}
// Restrict the search to specific languages.
$this->or_query->setLanguages([$lang]);