fix #1816 solr too many boolean clauses

This commit is contained in:
Bachir Soussi Chiadmi 2022-08-15 17:30:59 +02:00
parent db6a82f7f7
commit 1c47278ae5
1 changed files with 13 additions and 8 deletions

View File

@ -169,12 +169,13 @@ class Base extends ControllerBase {
$this->or_query->keys(implode(' ', $this->keys)); $this->or_query->keys(implode(' ', $this->keys));
} }
// exclude results from and_query // // exclude results from previous and_query
$exclude_and_results_conditions = $this->or_query->createConditionGroup('AND'); // !! trigering solr "too many boolean clauses" error
foreach ($this->results['nids'] as $nid) { // $exclude_and_results_conditions = $this->or_query->createConditionGroup('AND');
$exclude_and_results_conditions->addCondition('nid', $nid, '<>'); // foreach ($this->results['nids'] as $nid) {
} // $exclude_and_results_conditions->addCondition('nid', $nid, '<>');
$this->or_query->addConditionGroup($exclude_and_results_conditions); // }
// $this->or_query->addConditionGroup($exclude_and_results_conditions);
if (preg_match_all('/[WTRPCMFGSO]\d{4}/i', implode(' ', $this->keys), $matches)) { if (preg_match_all('/[WTRPCMFGSO]\d{4}/i', implode(' ', $this->keys), $matches)) {
// in case we search for material references like W0117 // in case we search for material references like W0117
@ -226,8 +227,12 @@ class Base extends ControllerBase {
$or_results = $this->or_query->execute(); $or_results = $this->or_query->execute();
foreach ($or_results as $result) { foreach ($or_results as $result) {
$nid = $result->getField('nid')->getValues()[0];
// !! have to remove duplicates instead of $exclude_and_results_conditions (solr too many boolean clauses)
if ( !in_array($nid, $this->results['nids']) ) {
$this->results['uuids'][] = $result->getField('uuid')->getValues()[0]; $this->results['uuids'][] = $result->getField('uuid')->getValues()[0];
$this->results['nids'][] = $result->getField('nid')->getValues()[0]; $this->results['nids'][] = $nid;
}
} }
// todo you may like / more like this // todo you may like / more like this