Skip to content

Commit

Permalink
Add method to remove mustClause in arSolrBoolQuery
Browse files Browse the repository at this point in the history
Add a metod to remove any term queries with a given field from the must
clause in arSolrBoolQuery.
  • Loading branch information
anvit committed Aug 21, 2024
1 parent 3f99b09 commit aabd964
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions plugins/arSolrPlugin/lib/query/arSolrBoolQuery.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,22 @@ public function getType()
return $this->type;
}

public function removeMustWithTermField($field)
{
$params = $this->getParams();
$mustParams = [];

foreach ($params['must'] as $query) {
if ($query instanceof arSolrTermQuery && $query->getTermField() === $field) {
continue;
}

array_push($mustParams, $params['must']);
}

$this->setParams('must', $mustParams);
}

protected function _addQuery(string $type, $args): self
{
if (!\is_array($args) && !($args instanceof arSolrAbstractQuery)) {
Expand Down

0 comments on commit aabd964

Please sign in to comment.