Skip to content

Commit d91adf5

Browse files
committed
feat(dart): searchWithOptionalFilters (+ local vars)
1 parent 387900e commit d91adf5

File tree

7 files changed

+47
-1
lines changed

7 files changed

+47
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{> snippets/import}}
2+
3+
final List<String> labels = []; // A list of labels
4+
5+
List<String> reduceLabelsToFilters(List<String> labels) {
6+
return []; // Implement your logic here
7+
}
8+
9+
void searchWithOptionalFilters() async {
10+
{{> snippets/init}}
11+
12+
final optionalFilters = reduceLabelsToFilters(labels);
13+
final searchParams = SearchParamsObject(query: "<YOUR_SEARCH_QUERY>", optionalFilters: optionalFilters);
14+
15+
await {{#dynamicSnippet}}searchWithSearchParams{{/dynamicSnippet}};
16+
}

templates/kotlin/guides/search/searchWithGAToken.mustache

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{{> snippets/import}}
22
import com.algolia.client.model.search.*
33

4+
val getGoogleAnalyticsUserIdFromBrowserCookie: (String) -> String = {
5+
"" // Implement your logic here
6+
}
7+
48
suspend fun searchWithGAToken() {
59
{{> snippets/init}}
610

@@ -9,7 +13,7 @@ suspend fun searchWithGAToken() {
913

1014
client.{{#dynamicSnippet}}searchWithSearchParams{{/dynamicSnippet}}
1115

12-
val loggedInUser = Some("...")
16+
val loggedInUser: String? = null
1317
searchParams = SearchParamsObject(query = "<YOUR_SEARCH_QUERY>", userToken = loggedInUser ?: userToken)
1418

1519
client.{{#dynamicSnippet}}searchWithSearchParams{{/dynamicSnippet}}

templates/kotlin/guides/search/searchWithOptionalFilters.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{{> snippets/import}}
22
import com.algolia.client.model.search.*
33

4+
val labels: List<String> = listOf() // A list of labels
5+
6+
val reduceLabelsToFilters: (List<String>) -> OptionalFilters = {
7+
OptionalFilters.of("") // Implement your logic here
8+
}
9+
410
suspend fun searchWithOptionalFilters() {
511
{{> snippets/init}}
612

templates/scala/guides/search/searchWithGAToken.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import scala.concurrent.duration.Duration
66
{{> snippets/import}}
77
import algoliasearch.search.SearchParamsObject
88

9+
val getGoogleAnalyticsUserIdFromBrowserCookie: String => String = _ => {
10+
"" // Implement your logic here
11+
}
12+
913
def searchWithGAToken(): Future[Unit] = {
1014
{{> snippets/init}}
1115

templates/scala/guides/search/searchWithOptionalFilters.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import scala.concurrent.duration.Duration
66
{{> snippets/import}}
77
import algoliasearch.search.SearchParamsObject
88

9+
val labels: List[String] = List() // A list of labels
10+
11+
val reduceLabelsToFilters: Seq[String] => SeqOfOptionalFilters = _ => {
12+
SeqOfOptionalFilters(Seq()) // Implement your logic here
13+
}
14+
915
def searchWithOptionalFilters(): Future[Unit] = {
1016
{{> snippets/init}}
1117

templates/swift/guides/search/searchWithGAToken.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import Foundation
66
import Core
77
{{> snippets/import}}
88

9+
let getGoogleAnalyticsUserIdFromBrowserCookie = {(_: String) in
10+
"" // Implement your logic here
11+
}
12+
913
func searchWithGAToken() async throws {
1014
do {
1115
{{> snippets/init}}

templates/swift/guides/search/searchWithOptionalFilters.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import Foundation
66
import Core
77
{{> snippets/import}}
88

9+
let labels: [String] = [] // A list of labels
10+
11+
let reduceLabelsToFilters = {(_: [String]) in
12+
SearchOptionalFilters.arrayOfSearchOptionalFilters([]) // Implement your logic here
13+
}
14+
915
func searchWithOptionalFilters() async throws {
1016
do {
1117
{{> snippets/init}}

0 commit comments

Comments
 (0)