Skip to content

Commit

Permalink
Escape query fields in Solr
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Feb 1, 2023
1 parent cf32175 commit a47e3ea
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/seal-solr-adapter/SolrConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ public function search(Search $search): Result
foreach ($search->filters as $filter) {
match (true) {
$filter instanceof Condition\SearchCondition => $queryText = $filter->query,
$filter instanceof Condition\IdentifierCondition => $filters[] = $index->getIdentifierField()->name . ':"' . $filter->identifier . '"', // TODO escape?
$filter instanceof Condition\EqualCondition => $filters[] = $filter->field . ':"' . $filter->value . '"', // TODO escape?
$filter instanceof Condition\NotEqualCondition => $filters[] = '-' . $filter->field . ':"' . $filter->value . '"', // TODO escape?
$filter instanceof Condition\GreaterThanCondition => $filters[] = $filter->field . ':{' . $filter->value . ' TO *}', // TODO escape?
$filter instanceof Condition\GreaterThanEqualCondition => $filters[] = $filter->field . ':[' . $filter->value . ' TO *]', // TODO escape?
$filter instanceof Condition\LessThanCondition => $filters[] = $filter->field . ':{* TO ' . $filter->value . '}', // TODO escape?
$filter instanceof Condition\LessThanEqualCondition => $filters[] = $filter->field . ':[* TO ' . $filter->value . ']', // TODO escape?
$filter instanceof Condition\IdentifierCondition => $filters[] = $index->getIdentifierField()->name . ':' . $helper->escapeTerm($filter->identifier),
$filter instanceof Condition\EqualCondition => $filters[] = $filter->field . ':' . $helper->escapeTerm($filter->value),
$filter instanceof Condition\NotEqualCondition => $filters[] = '-' . $filter->field . ':' . $helper->escapeTerm($helper->escapeTerm($filter->value)),
$filter instanceof Condition\GreaterThanCondition => $filters[] = $filter->field . ':{' . $helper->escapeTerm($filter->value) . ' TO *}',
$filter instanceof Condition\GreaterThanEqualCondition => $filters[] = $filter->field . ':[' . $helper->escapeTerm($filter->value) . ' TO *]',
$filter instanceof Condition\LessThanCondition => $filters[] = $filter->field . ':{* TO ' . $helper->escapeTerm($filter->value) . '}',
$filter instanceof Condition\LessThanEqualCondition => $filters[] = $filter->field . ':[* TO ' . $helper->escapeTerm($filter->value) . ']',
default => throw new \LogicException($filter::class . ' filter not implemented.'),
};
}
Expand Down

0 comments on commit a47e3ea

Please sign in to comment.