created sapi processor to unindex unused taxo terms, added term id condition on sapi query

This commit is contained in:
2021-02-24 14:14:56 +01:00
parent 9f0b257c62
commit 182b61b08f
5 changed files with 145 additions and 16 deletions

View File

@@ -40,11 +40,25 @@ class Base extends ControllerBase {
// Set additional conditions.
// in case we search for material references like W0117
if (preg_match_all('/[WTRPCMFGSO]\d{4}/i', $this->keys, $matches)) {
$conditions = $this->query->createConditionGroup('OR');
$ref_conditions = $this->query->createConditionGroup('OR');
foreach ($matches[0] as $key => $value) {
$conditions->addCondition('field_reference', $value);
$ref_conditions->addCondition('field_reference', $value);
}
$this->query->addConditionGroup($conditions);
$this->query->addConditionGroup($ref_conditions);
}
// in case of term id provided restrict the keys to taxo fields
if ($this->term) {
$term_conditions = $this->query->createConditionGroup('OR');
$term = (int) $this->term;
foreach (['tag_tid', 'thesaurus_tid'] as $field) {
$term_conditions->addCondition($field, $term);
}
// foreach (['tag_name', 'thesaurus_name'] as $field) {
// $term_conditions->addCondition($field, $this->keys);
// }
// $term_conditions->addCondition('tag_name', $this->keys);
// $term_conditions->addCondition('thesaurus_name', $this->keys);
$this->query->addConditionGroup($term_conditions);
}
// Restrict the search to specific languages.