Skip to content

Commit

Permalink
fix(specs): make the searchParams compatible with v4 [skip-bc] (gener…
Browse files Browse the repository at this point in the history
…ated)

algolia/api-clients-automation#4108

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
algolia-bot and millotp committed Nov 15, 2024
1 parent fe4a888 commit db1b3c7
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public fun SearchForHits.Companion.from(
replaceSynonymsInHighlight = searchParamsObject.replaceSynonymsInHighlight,
minProximity = searchParamsObject.minProximity,
responseFields = searchParamsObject.responseFields,
maxFacetHits = searchParamsObject.maxFacetHits,
maxValuesPerFacet = searchParamsObject.maxValuesPerFacet,
sortFacetValuesBy = searchParamsObject.sortFacetValuesBy,
attributeCriteriaComputedByMinProximity = searchParamsObject.attributeCriteriaComputedByMinProximity,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.recommend

import com.algolia.client.exception.AlgoliaClientException
import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
import kotlin.jvm.JvmInline

/**
* InsideBoundingBox
*
* Implementations:
* - [List<List<Double>>] - *[InsideBoundingBox.of]*
* - [String] - *[InsideBoundingBox.of]*
*/
@Serializable(InsideBoundingBoxSerializer::class)
public sealed interface InsideBoundingBox {
@Serializable
@JvmInline
public value class StringValue(public val value: String) : InsideBoundingBox

@Serializable
@JvmInline
public value class ListOfListOfDoubleValue(public val value: List<List<Double>>) : InsideBoundingBox

public companion object {

public fun of(value: String): InsideBoundingBox {
return StringValue(value)
}
public fun of(value: List<List<Double>>): InsideBoundingBox {
return ListOfListOfDoubleValue(value)
}
}
}

internal class InsideBoundingBoxSerializer : JsonContentPolymorphicSerializer<InsideBoundingBox>(InsideBoundingBox::class) {
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<InsideBoundingBox> {
return when {
element.isString -> InsideBoundingBox.StringValue.serializer()
element is JsonArray -> InsideBoundingBox.ListOfListOfDoubleValue.serializer()
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.recommend

import com.algolia.client.exception.AlgoliaClientException
import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
import kotlin.jvm.JvmInline

/**
* OptionalWords
*
* Implementations:
* - [List<String>] - *[OptionalWords.of]*
* - [String] - *[OptionalWords.of]*
*/
@Serializable(OptionalWordsSerializer::class)
public sealed interface OptionalWords {
@Serializable
@JvmInline
public value class StringValue(public val value: String) : OptionalWords

@Serializable
@JvmInline
public value class ListOfStringValue(public val value: List<String>) : OptionalWords

public companion object {

public fun of(value: String): OptionalWords {
return StringValue(value)
}
public fun of(value: List<String>): OptionalWords {
return ListOfStringValue(value)
}
}
}

internal class OptionalWordsSerializer : JsonContentPolymorphicSerializer<OptionalWords>(OptionalWords::class) {
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<OptionalWords> {
return when {
element.isString -> OptionalWords.StringValue.serializer()
element is JsonArray -> OptionalWords.ListOfStringValue.serializer()
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import kotlinx.serialization.json.*
* @param aroundRadius
* @param aroundPrecision
* @param minimumAroundRadius Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.
* @param insideBoundingBox Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide multiple bounding boxes as nested arrays. For more information, see [rectangular area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas).
* @param insideBoundingBox
* @param insidePolygon Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). This parameter is ignored if you also specify `insideBoundingBox`.
* @param naturalLanguages ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to keyword searches): - Sets `removeStopWords` and `ignorePlurals` to the list of provided languages. - Sets `removeWordsIfNoResults` to `allOptional`. - Adds a `natural_language` attribute to `ruleContexts` and `analyticsTags`.
* @param ruleContexts Assigns a rule context to the search query. [Rule contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context) are strings that you can use to trigger matching rules.
Expand Down Expand Up @@ -67,7 +67,7 @@ import kotlinx.serialization.json.*
* @param mode
* @param semanticSearch
* @param advancedSyntax Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported.
* @param optionalWords Words that should be considered optional when found in the query. By default, records must match all words in the search query to be included in the search results. Adding optional words can help to increase the number of search results by running an additional search query that doesn't include the optional words. For example, if the search query is \"action video\" and \"video\" is an optional word, the search engine runs two queries. One for \"action video\" and one for \"action\". Records that match all words are ranked higher. For a search query with 4 or more words **and** all its words are optional, the number of matched words required for a record to be included in the search results increases for every 1,000 records: - If `optionalWords` has less than 10 words, the required number of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched words. - If `optionalWords` has 10 or more words, the number of required matched words increases by the number of optional words divided by 5 (rounded down). For example, with 18 optional words: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 4 matched words. For more information, see [Optional words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words).
* @param optionalWords
* @param disableExactOnAttributes Searchable attributes for which you want to [turn off the Exact ranking criterion](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/override-search-engine-defaults/in-depth/adjust-exact-settings/#turn-off-exact-for-some-attributes). Attribute names are case-sensitive. This can be useful for attributes with long values, where the likelihood of an exact match is high, such as product descriptions. Turning off the Exact ranking criterion for these attributes favors exact matching on other attributes. This reduces the impact of individual attributes with a lot of content on ranking.
* @param exactOnSingleWordQuery
* @param alternativesAsExact Determine which plurals and synonyms should be considered an exact matches. By default, Algolia treats singular and plural forms of a word, and single-word synonyms, as [exact](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/#exact) matches when searching. For example: - \"swimsuit\" and \"swimsuits\" are treated the same - \"swimsuit\" and \"swimwear\" are treated the same (if they are [synonyms](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/#regular-synonyms)). - `ignorePlurals`. Plurals and similar declensions added by the `ignorePlurals` setting are considered exact matches. - `singleWordSynonym`. Single-word synonyms, such as \"NY\" = \"NYC\", are considered exact matches. - `multiWordsSynonym`. Multi-word synonyms, such as \"NY\" = \"New York\", are considered exact matches.
Expand All @@ -76,7 +76,6 @@ import kotlinx.serialization.json.*
* @param replaceSynonymsInHighlight Whether to replace a highlighted word with the matched synonym. By default, the original words are highlighted even if a synonym matches. For example, with `home` as a synonym for `house` and a search for `home`, records matching either \"home\" or \"house\" are included in the search results, and either \"home\" or \"house\" are highlighted. With `replaceSynonymsInHighlight` set to `true`, a search for `home` still matches the same records, but all occurrences of \"house\" are replaced by \"home\" in the highlighted response.
* @param minProximity Minimum proximity score for two matching words. This adjusts the [Proximity ranking criterion](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/#proximity) by equally scoring matches that are farther apart. For example, if `minProximity` is 2, neighboring matches and matches with one word between them would have the same score.
* @param responseFields Properties to include in the API response of `search` and `browse` requests. By default, all response properties are included. To reduce the response size, you can select, which attributes should be included. You can't exclude these properties: `message`, `warning`, `cursor`, `serverUsed`, `indexUsed`, `abTestVariantID`, `parsedQuery`, or any property triggered by the `getRankingInfo` parameter. Don't exclude properties that you might need in your search UI.
* @param maxFacetHits Maximum number of facet values to return when [searching for facet values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
* @param maxValuesPerFacet Maximum number of facet values to return for each facet.
* @param sortFacetValuesBy Order in which to retrieve facet values. - `count`. Facet values are retrieved by decreasing count. The count is the number of matching records containing this facet value. - `alpha`. Retrieve facet values alphabetically. This setting doesn't influence how facet values are displayed in your UI (see `renderingContent`). For more information, see [facet value display](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/facet-display/js/).
* @param attributeCriteriaComputedByMinProximity Whether the best matching attribute should be determined by minimum proximity. This setting only affects ranking if the Attribute ranking criterion comes before Proximity in the `ranking` setting. If true, the best matching attribute is selected based on the minimum proximity of multiple matches. Otherwise, the best matching attribute is determined by the order in the `searchableAttributes` setting.
Expand Down Expand Up @@ -139,8 +138,7 @@ public data class BrowseParamsObject(
/** Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. */
@SerialName(value = "minimumAroundRadius") val minimumAroundRadius: Int? = null,

/** Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide multiple bounding boxes as nested arrays. For more information, see [rectangular area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). */
@SerialName(value = "insideBoundingBox") val insideBoundingBox: List<List<Double>>? = null,
@SerialName(value = "insideBoundingBox") val insideBoundingBox: InsideBoundingBox? = null,

/** Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). This parameter is ignored if you also specify `insideBoundingBox`. */
@SerialName(value = "insidePolygon") val insidePolygon: List<List<Double>>? = null,
Expand Down Expand Up @@ -255,8 +253,7 @@ public data class BrowseParamsObject(
/** Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. */
@SerialName(value = "advancedSyntax") val advancedSyntax: Boolean? = null,

/** Words that should be considered optional when found in the query. By default, records must match all words in the search query to be included in the search results. Adding optional words can help to increase the number of search results by running an additional search query that doesn't include the optional words. For example, if the search query is \"action video\" and \"video\" is an optional word, the search engine runs two queries. One for \"action video\" and one for \"action\". Records that match all words are ranked higher. For a search query with 4 or more words **and** all its words are optional, the number of matched words required for a record to be included in the search results increases for every 1,000 records: - If `optionalWords` has less than 10 words, the required number of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched words. - If `optionalWords` has 10 or more words, the number of required matched words increases by the number of optional words divided by 5 (rounded down). For example, with 18 optional words: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 4 matched words. For more information, see [Optional words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words). */
@SerialName(value = "optionalWords") val optionalWords: List<String>? = null,
@SerialName(value = "optionalWords") val optionalWords: OptionalWords? = null,

/** Searchable attributes for which you want to [turn off the Exact ranking criterion](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/override-search-engine-defaults/in-depth/adjust-exact-settings/#turn-off-exact-for-some-attributes). Attribute names are case-sensitive. This can be useful for attributes with long values, where the likelihood of an exact match is high, such as product descriptions. Turning off the Exact ranking criterion for these attributes favors exact matching on other attributes. This reduces the impact of individual attributes with a lot of content on ranking. */
@SerialName(value = "disableExactOnAttributes") val disableExactOnAttributes: List<String>? = null,
Expand All @@ -280,9 +277,6 @@ public data class BrowseParamsObject(
/** Properties to include in the API response of `search` and `browse` requests. By default, all response properties are included. To reduce the response size, you can select, which attributes should be included. You can't exclude these properties: `message`, `warning`, `cursor`, `serverUsed`, `indexUsed`, `abTestVariantID`, `parsedQuery`, or any property triggered by the `getRankingInfo` parameter. Don't exclude properties that you might need in your search UI. */
@SerialName(value = "responseFields") val responseFields: List<String>? = null,

/** Maximum number of facet values to return when [searching for facet values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values). */
@SerialName(value = "maxFacetHits") val maxFacetHits: Int? = null,

/** Maximum number of facet values to return for each facet. */
@SerialName(value = "maxValuesPerFacet") val maxValuesPerFacet: Int? = null,

Expand Down
Loading

0 comments on commit db1b3c7

Please sign in to comment.