File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
src/commonTest/kotlin/documentation/guides/rule Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ package documentation.guides.rule
2+
3+ import com.algolia.search.dsl.attributesForFaceting
4+ import com.algolia.search.dsl.optionalFilters
5+ import com.algolia.search.dsl.query
6+ import com.algolia.search.dsl.settings
7+ import documentation.index
8+ import runBlocking
9+ import kotlin.test.Ignore
10+
11+ @Ignore
12+ class GuideOptionalFilters {
13+
14+ /* * Optional filter **/
15+ fun snippet1 () {
16+ runBlocking {
17+ val query = query(" phone" ) {
18+ optionalFilters {
19+ and {
20+ facet(" brand" , " Apple" , score = 3 )
21+ facet(" brand" , " Samsung" , score = 2 )
22+ facet(" brand" , " -Huawei" )
23+ }
24+ }
25+ }
26+ index.search(query = query)
27+ }
28+ }
29+
30+ /* * Filter score **/
31+ fun snippet2 () {
32+ runBlocking {
33+ val query = query {
34+ optionalFilters {
35+ and {
36+ facet(" brand" , " Apple" , score = 2 )
37+ facet(" type" , " tablet" )
38+ }
39+ }
40+ }
41+ index.search(query = query)
42+ }
43+ }
44+
45+ /* * Filter only faceting **/
46+ fun snippets3 () {
47+ runBlocking {
48+ val settings = settings {
49+ attributesForFaceting {
50+ + " filterOnly(brand)"
51+ }
52+ }
53+ index.setSettings(settings)
54+ }
55+ }
56+ }
You can’t perform that action at this time.
0 commit comments