Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsonapi_search_api
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
jsonapi_search_api
Commits
ae0b7be5
Commit
ae0b7be5
authored
1 month ago
by
Jonathan Sacksick
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3498459
: Incorrect condition groups nesting leads to incorrect facets count
parent
7d6842b4
No related branches found
No related tags found
1 merge request
!17
Issue #3498459 by nixou, jsacksick: Incorrect condition groups nesting leads...
Pipeline
#450232
passed
1 month ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/jsonapi_search_api_facets/tests/src/Functional/IndexFacetsTest.php
+1
-1
1 addition, 1 deletion
...earch_api_facets/tests/src/Functional/IndexFacetsTest.php
src/Resource/IndexResource.php
+14
-1
14 additions, 1 deletion
src/Resource/IndexResource.php
with
15 additions
and
2 deletions
modules/jsonapi_search_api_facets/tests/src/Functional/IndexFacetsTest.php
+
1
−
1
View file @
ae0b7be5
...
@@ -272,7 +272,7 @@ final class IndexFacetsTest extends BrowserTestBase {
...
@@ -272,7 +272,7 @@ final class IndexFacetsTest extends BrowserTestBase {
'condition'
=>
[
'condition'
=>
[
'path'
=>
'keywords'
,
'path'
=>
'keywords'
,
'operator'
=>
'IN'
,
'operator'
=>
'IN'
,
'value'
=>
[
'grape'
,
'strawberry'
],
'value'
=>
[
'grape'
,
'strawberry'
,
'banana'
,
'apple'
],
],
],
],
],
];
];
...
...
This diff is collapsed.
Click to expand it.
src/Resource/IndexResource.php
+
14
−
1
View file @
ae0b7be5
...
@@ -21,6 +21,8 @@ use Drupal\search_api\IndexInterface;
...
@@ -21,6 +21,8 @@ use Drupal\search_api\IndexInterface;
use
Drupal\search_api
\Item\ItemInterface
;
use
Drupal\search_api
\Item\ItemInterface
;
use
Drupal\search_api
\ParseMode\ParseModeInterface
;
use
Drupal\search_api
\ParseMode\ParseModeInterface
;
use
Drupal\search_api
\ParseMode\ParseModePluginManager
;
use
Drupal\search_api
\ParseMode\ParseModePluginManager
;
use
Drupal\search_api
\Query\ConditionGroupInterface
;
use
Drupal\search_api
\Query\ConditionInterface
;
use
Drupal\search_api
\Query\QueryInterface
;
use
Drupal\search_api
\Query\QueryInterface
;
use
Drupal\search_api
\SearchApiException
;
use
Drupal\search_api
\SearchApiException
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
...
@@ -170,7 +172,18 @@ final class IndexResource extends EntityResourceBase implements ContainerInjecti
...
@@ -170,7 +172,18 @@ final class IndexResource extends EntityResourceBase implements ContainerInjecti
}
}
try
{
try
{
$filter
=
Filter
::
createFromQueryParameter
(
$filter
);
$filter
=
Filter
::
createFromQueryParameter
(
$filter
);
$query
->
addConditionGroup
(
$filter
->
queryCondition
(
$query
));
$root_group
=
$query
->
getConditionGroup
();
$new_group
=
$filter
->
queryCondition
(
$query
);
foreach
(
$new_group
->
getConditions
()
as
$element
)
{
if
(
$element
instanceof
ConditionInterface
)
{
$root_group
->
addCondition
(
$element
->
getField
(),
$element
->
getValue
(),
$element
->
getOperator
());
}
elseif
(
$element
instanceof
ConditionGroupInterface
)
{
$root_group
->
addConditionGroup
(
$element
);
}
}
}
}
catch
(
\Exception
$exception
)
{
catch
(
\Exception
$exception
)
{
throw
new
CacheableBadRequestHttpException
(
$cacheability
,
$exception
->
getMessage
());
throw
new
CacheableBadRequestHttpException
(
$cacheability
,
$exception
->
getMessage
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment