Skip to content

Commit

Permalink
feat(dart): searchWithOptionalFilters (+ local vars)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fluf22 committed Jan 24, 2025
1 parent 387900e commit d91adf5
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 1 deletion.
16 changes: 16 additions & 0 deletions templates/dart/guides/search/searchWithOptionalFilters.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{> snippets/import}}

final List<String> labels = []; // A list of labels

List<String> reduceLabelsToFilters(List<String> labels) {
return []; // Implement your logic here
}

void searchWithOptionalFilters() async {
{{> snippets/init}}

final optionalFilters = reduceLabelsToFilters(labels);
final searchParams = SearchParamsObject(query: "<YOUR_SEARCH_QUERY>", optionalFilters: optionalFilters);

await {{#dynamicSnippet}}searchWithSearchParams{{/dynamicSnippet}};
}
6 changes: 5 additions & 1 deletion templates/kotlin/guides/search/searchWithGAToken.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{{> snippets/import}}
import com.algolia.client.model.search.*

val getGoogleAnalyticsUserIdFromBrowserCookie: (String) -> String = {
"" // Implement your logic here
}

suspend fun searchWithGAToken() {
{{> snippets/init}}

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

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

val loggedInUser = Some("...")
val loggedInUser: String? = null
searchParams = SearchParamsObject(query = "<YOUR_SEARCH_QUERY>", userToken = loggedInUser ?: userToken)

client.{{#dynamicSnippet}}searchWithSearchParams{{/dynamicSnippet}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{{> snippets/import}}
import com.algolia.client.model.search.*

val labels: List<String> = listOf() // A list of labels

val reduceLabelsToFilters: (List<String>) -> OptionalFilters = {
OptionalFilters.of("") // Implement your logic here
}

suspend fun searchWithOptionalFilters() {
{{> snippets/init}}

Expand Down
4 changes: 4 additions & 0 deletions templates/scala/guides/search/searchWithGAToken.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import scala.concurrent.duration.Duration
{{> snippets/import}}
import algoliasearch.search.SearchParamsObject

val getGoogleAnalyticsUserIdFromBrowserCookie: String => String = _ => {
"" // Implement your logic here
}

def searchWithGAToken(): Future[Unit] = {
{{> snippets/init}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import scala.concurrent.duration.Duration
{{> snippets/import}}
import algoliasearch.search.SearchParamsObject

val labels: List[String] = List() // A list of labels

val reduceLabelsToFilters: Seq[String] => SeqOfOptionalFilters = _ => {
SeqOfOptionalFilters(Seq()) // Implement your logic here
}

def searchWithOptionalFilters(): Future[Unit] = {
{{> snippets/init}}

Expand Down
4 changes: 4 additions & 0 deletions templates/swift/guides/search/searchWithGAToken.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import Foundation
import Core
{{> snippets/import}}

let getGoogleAnalyticsUserIdFromBrowserCookie = {(_: String) in
"" // Implement your logic here
}

func searchWithGAToken() async throws {
do {
{{> snippets/init}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import Foundation
import Core
{{> snippets/import}}

let labels: [String] = [] // A list of labels

let reduceLabelsToFilters = {(_: [String]) in
SearchOptionalFilters.arrayOfSearchOptionalFilters([]) // Implement your logic here
}

func searchWithOptionalFilters() async throws {
do {
{{> snippets/init}}
Expand Down

0 comments on commit d91adf5

Please sign in to comment.