Skip to content

Commit 216ea0b

Browse files
committed
Update GuideHideHits
1 parent a10b82f commit 216ea0b

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/commonTest/kotlin/documentation/guides/results/promoting/GuideHideHits.kt

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package documentation.guides.results.promoting
22

3+
import com.algolia.search.dsl.filters
34
import com.algolia.search.dsl.objectIDs
5+
import com.algolia.search.dsl.query
46
import com.algolia.search.dsl.rule.rules
7+
import com.algolia.search.model.rule.Anchoring
58
import com.algolia.search.model.rule.Condition
69
import com.algolia.search.model.rule.Consequence
10+
import com.algolia.search.model.rule.Pattern
711
import documentation.index
812
import runBlocking
913
import kotlin.test.Ignore
@@ -18,9 +22,33 @@ internal class GuideHideHits {
1822
runBlocking {
1923
val rules = rules {
2024
rule(
21-
"hide-12345",
22-
Condition(Contains, Literal("harry potter")),
23-
Consequence(hide = objectIDs { +"HP-12345" })
25+
objectID = "hide-12345",
26+
condition = Condition(Contains, Literal("harry potter")),
27+
consequence = Consequence(hide = objectIDs { +"HP-12345" })
28+
)
29+
}
30+
31+
index.saveRules(rules)
32+
}
33+
}
34+
35+
@Test
36+
fun snippet2() {
37+
runBlocking {
38+
val rules = rules {
39+
rule(
40+
objectID = "hide-shirts",
41+
condition = Condition(
42+
pattern = Pattern.Literal("banana"),
43+
anchoring = Anchoring.Is
44+
),
45+
consequence = Consequence(
46+
query = query {
47+
filters {
48+
and { facet("clothing-type", "t-shirts", isNegated = true) }
49+
}
50+
}
51+
)
2452
)
2553
}
2654

0 commit comments

Comments
 (0)