From 1382fcde914d4e6c9ad6499a31b1e3ea3a3579e3 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 1 Feb 2023 01:44:37 +0100 Subject: [PATCH] Add LessThan, LessThanEqual, GreaterThan, GreaterThanEqual Conditions to Solr --- packages/seal-solr-adapter/SolrConnection.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/seal-solr-adapter/SolrConnection.php b/packages/seal-solr-adapter/SolrConnection.php index 01f0ebbd..b4bd024c 100644 --- a/packages/seal-solr-adapter/SolrConnection.php +++ b/packages/seal-solr-adapter/SolrConnection.php @@ -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 . '', // TODO escape? - $filter instanceof Condition\GreaterThanEqualCondition => $filters[] = $filter->field . ' > ' . $filter->value . '', // TODO escape? - $filter instanceof Condition\LessThanCondition => $filters[] = $filter->field . ' <= ' . $filter->value . '', // TODO escape? - $filter instanceof Condition\LessThanEqualCondition => $filters[] = $filter->field . ' < ' . $filter->value . '', // TODO escape? + $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? default => throw new \LogicException($filter::class . ' filter not implemented.'), }; }