Skip to content

Commit 048985c

Browse files
authored
Support doesNotAffect arg for relevant operators (#1927)
Also adds the examples from facet documentation (which shows only the `equals` operator with the new argument)
1 parent 7ba853f commit 048985c

8 files changed

Lines changed: 287 additions & 7 deletions

File tree

src/Builder/Search/CompoundOperator.php

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Search/EqualsOperator.php

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Search/FactoryTrait.php

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Search/InOperator.php

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Search/RangeOperator.php

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Builder/Search/FacetOperatorTest.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,88 @@ public function testFacet(): void
5959

6060
$this->assertSamePipeline(Pipelines::FacetFacet, $pipeline);
6161
}
62+
63+
public function testInterFacetFilterExclusionExample(): void
64+
{
65+
$pipeline = new Pipeline(
66+
Stage::searchMeta(
67+
Search::facet(
68+
facets: object(
69+
accommodatesFacet: object(
70+
path: 'accommodates',
71+
type: 'number',
72+
boundaries: [1, 2, 4, 8],
73+
),
74+
cancellationFacet: object(
75+
path: 'cancellation_policy',
76+
type: 'string',
77+
),
78+
roomTypeFacet: object(
79+
path: 'room_type',
80+
type: 'string',
81+
),
82+
),
83+
operator: Search::compound(
84+
must: [
85+
Search::text(
86+
path: 'description',
87+
query: 'new york city',
88+
),
89+
],
90+
filter: [
91+
Search::equals(
92+
path: 'cancellation_policy',
93+
value: 'moderate',
94+
doesNotAffect: 'accommodatesFacet',
95+
),
96+
],
97+
),
98+
),
99+
),
100+
);
101+
102+
$this->assertSamePipeline(Pipelines::FacetInterFacetFilterExclusionExample, $pipeline);
103+
}
104+
105+
public function testMultiSelectFacetingExample(): void
106+
{
107+
$pipeline = new Pipeline(
108+
Stage::searchMeta(
109+
Search::facet(
110+
facets: object(
111+
accommodatesFacet: object(
112+
path: 'accommodates',
113+
type: 'number',
114+
boundaries: [1, 2, 4, 8],
115+
),
116+
cancellationFacet: object(
117+
path: 'cancellation_policy',
118+
type: 'string',
119+
),
120+
roomTypeFacet: object(
121+
path: 'room_type',
122+
type: 'string',
123+
),
124+
),
125+
operator: Search::compound(
126+
must: [
127+
Search::text(
128+
path: 'description',
129+
query: 'new york city',
130+
),
131+
],
132+
filter: [
133+
Search::equals(
134+
path: 'cancellation_policy',
135+
value: 'moderate',
136+
doesNotAffect: 'cancellationFacet',
137+
),
138+
],
139+
),
140+
),
141+
),
142+
);
143+
144+
$this->assertSamePipeline(Pipelines::FacetMultiSelectFacetingExample, $pipeline);
145+
}
62146
}

0 commit comments

Comments
 (0)