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 92cb2bb commit 5bdc106
Show file tree
Hide file tree
Showing 24 changed files with 347 additions and 284 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ import algoliasearch.recommend.SupportedLanguage._
* `distinct` search parameter to control how many items per group are included in the search results. If you want to
* use the same attribute also for faceting, use the `afterDistinct` modifier of the `attributesForFaceting` setting.
* This applies faceting _after_ deduplication, which will result in accurate facet counts.
* @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).
*/
case class BaseIndexSettings(
attributesForFaceting: Option[Seq[String]] = scala.None,
Expand All @@ -153,5 +156,6 @@ case class BaseIndexSettings(
searchableAttributes: Option[Seq[String]] = scala.None,
userData: Option[Any] = scala.None,
customNormalization: Option[Map[String, Map[String, String]]] = scala.None,
attributeForDistinct: Option[String] = scala.None
attributeForDistinct: Option[String] = scala.None,
maxFacetHits: Option[Int] = scala.None
)
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,6 @@ import algoliasearch.recommend.SupportedLanguage._
* @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 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).
Expand Down Expand Up @@ -174,9 +161,6 @@ import algoliasearch.recommend.SupportedLanguage._
* 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
Expand Down Expand Up @@ -218,7 +202,7 @@ case class BaseRecommendIndexSettings(
queryType: Option[QueryType] = scala.None,
removeWordsIfNoResults: Option[RemoveWordsIfNoResults] = scala.None,
advancedSyntax: Option[Boolean] = scala.None,
optionalWords: Option[Seq[String]] = scala.None,
optionalWords: Option[OptionalWords] = scala.None,
disableExactOnAttributes: Option[Seq[String]] = scala.None,
exactOnSingleWordQuery: Option[ExactOnSingleWordQuery] = scala.None,
alternativesAsExact: Option[Seq[AlternativesAsExact]] = scala.None,
Expand All @@ -227,7 +211,6 @@ case class BaseRecommendIndexSettings(
replaceSynonymsInHighlight: Option[Boolean] = scala.None,
minProximity: Option[Int] = scala.None,
responseFields: Option[Seq[String]] = scala.None,
maxFacetHits: Option[Int] = scala.None,
maxValuesPerFacet: Option[Int] = scala.None,
sortFacetValuesBy: Option[String] = scala.None,
attributeCriteriaComputedByMinProximity: Option[Boolean] = scala.None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ import algoliasearch.recommend.SupportedLanguage._
* Whether to obtain the coordinates from the request's IP address.
* @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 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
Expand Down Expand Up @@ -138,7 +133,7 @@ case class BaseRecommendSearchParams(
aroundRadius: Option[AroundRadius] = scala.None,
aroundPrecision: Option[AroundPrecision] = scala.None,
minimumAroundRadius: Option[Int] = scala.None,
insideBoundingBox: Option[Seq[Seq[Double]]] = scala.None,
insideBoundingBox: Option[InsideBoundingBox] = scala.None,
insidePolygon: Option[Seq[Seq[Double]]] = scala.None,
naturalLanguages: Option[Seq[SupportedLanguage]] = scala.None,
ruleContexts: Option[Seq[String]] = scala.None,
Expand Down
30 changes: 6 additions & 24 deletions src/main/scala/algoliasearch/recommend/FallbackParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ import algoliasearch.recommend.SupportedLanguage._
* Whether to obtain the coordinates from the request's IP address.
* @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 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
Expand Down Expand Up @@ -230,6 +225,9 @@ import algoliasearch.recommend.SupportedLanguage._
* `distinct` search parameter to control how many items per group are included in the search results. If you want to
* use the same attribute also for faceting, use the `afterDistinct` modifier of the `attributesForFaceting` setting.
* This applies faceting _after_ deduplication, which will result in accurate facet counts.
* @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 attributesToRetrieve
* Attributes to include in the API response. To reduce the size of your response, you can retrieve only some of the
* attributes. Attribute names are case-sensitive. - `*` retrieves all attributes, except attributes included in the
Expand Down Expand Up @@ -314,19 +312,6 @@ import algoliasearch.recommend.SupportedLanguage._
* @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 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).
Expand Down Expand Up @@ -366,9 +351,6 @@ import algoliasearch.recommend.SupportedLanguage._
* 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
Expand Down Expand Up @@ -402,7 +384,7 @@ case class FallbackParams(
aroundRadius: Option[AroundRadius] = scala.None,
aroundPrecision: Option[AroundPrecision] = scala.None,
minimumAroundRadius: Option[Int] = scala.None,
insideBoundingBox: Option[Seq[Seq[Double]]] = scala.None,
insideBoundingBox: Option[InsideBoundingBox] = scala.None,
insidePolygon: Option[Seq[Seq[Double]]] = scala.None,
naturalLanguages: Option[Seq[SupportedLanguage]] = scala.None,
ruleContexts: Option[Seq[String]] = scala.None,
Expand Down Expand Up @@ -433,6 +415,7 @@ case class FallbackParams(
userData: Option[Any] = scala.None,
customNormalization: Option[Map[String, Map[String, String]]] = scala.None,
attributeForDistinct: Option[String] = scala.None,
maxFacetHits: Option[Int] = scala.None,
attributesToRetrieve: Option[Seq[String]] = scala.None,
ranking: Option[Seq[String]] = scala.None,
relevancyStrictness: Option[Int] = scala.None,
Expand All @@ -456,7 +439,7 @@ case class FallbackParams(
queryType: Option[QueryType] = scala.None,
removeWordsIfNoResults: Option[RemoveWordsIfNoResults] = scala.None,
advancedSyntax: Option[Boolean] = scala.None,
optionalWords: Option[Seq[String]] = scala.None,
optionalWords: Option[OptionalWords] = scala.None,
disableExactOnAttributes: Option[Seq[String]] = scala.None,
exactOnSingleWordQuery: Option[ExactOnSingleWordQuery] = scala.None,
alternativesAsExact: Option[Seq[AlternativesAsExact]] = scala.None,
Expand All @@ -465,7 +448,6 @@ case class FallbackParams(
replaceSynonymsInHighlight: Option[Boolean] = scala.None,
minProximity: Option[Int] = scala.None,
responseFields: Option[Seq[String]] = scala.None,
maxFacetHits: Option[Int] = scala.None,
maxValuesPerFacet: Option[Int] = scala.None,
sortFacetValuesBy: Option[String] = scala.None,
attributeCriteriaComputedByMinProximity: Option[Boolean] = scala.None,
Expand Down
70 changes: 70 additions & 0 deletions src/main/scala/algoliasearch/recommend/InsideBoundingBox.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/** Recommend API The Recommend API lets you retrieve recommendations from one of Algolia's AI recommendation models
* that you previously trained on your data. ## Client libraries Use Algolia's API clients and libraries to reliably
* integrate Algolia's APIs with your apps. The official API clients are covered by Algolia's [Service Level
* Agreement](https://www.algolia.com/policies/sla/). See: [Algolia's
* ecosystem](https://www.algolia.com/doc/guides/getting-started/how-algolia-works/in-depth/ecosystem/) ## Base URLs
* The base URLs for requests to the Recommend API are: - `https://{APPLICATION_ID}.algolia.net` -
* `https://{APPLICATION_ID}-dsn.algolia.net`. If your subscription includes a [Distributed Search
* Network](https://dashboard.algolia.com/infra), this ensures that requests are sent to servers closest to users. Both
* URLs provide high availability by distributing requests with load balancing. **All requests must use HTTPS.** ##
* Retry strategy To guarantee a high availability, implement a retry strategy for all API requests using the URLs of
* your servers as fallbacks: - `https://{APPLICATION_ID}-1.algolianet.com` -
* `https://{APPLICATION_ID}-2.algolianet.com` - `https://{APPLICATION_ID}-3.algolianet.com` These URLs use a different
* DNS provider than the primary URLs. You should randomize this list to ensure an even load across the three servers.
* All Algolia API clients implement this retry strategy. ## Authentication To authenticate your API requests, add
* these headers: - `x-algolia-application-id`. Your Algolia application ID. - `x-algolia-api-key`. An API key with the
* necessary permissions to make the request. The required access control list (ACL) to make a request is listed in
* each endpoint's reference. You can find your application ID and API key in the [Algolia
* dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must be JSON objects. ##
* Response status and errors The Recommend API returns JSON responses. Since JSON doesn't guarantee any specific
* ordering, don't rely on the order of attributes in the API response. Successful responses return a `2xx` status.
* Client errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
* property with more information. ## Version The current version of the Recommend API is version 1, as indicated by
* the `/1/` in each endpoint's URL.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech Do not edit the class manually.
*/
package algoliasearch.recommend

import org.json4s._

/** InsideBoundingBox
*/
sealed trait InsideBoundingBox

object InsideBoundingBox {

case class StringValue(value: String) extends InsideBoundingBox
case class SeqOfSeqOfDouble(value: Seq[Seq[Double]]) extends InsideBoundingBox

def apply(value: String): InsideBoundingBox = {
InsideBoundingBox.StringValue(value)
}
def apply(value: Seq[Seq[Double]]): InsideBoundingBox = {
InsideBoundingBox.SeqOfSeqOfDouble(value)
}

}

object InsideBoundingBoxSerializer extends Serializer[InsideBoundingBox] {
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), InsideBoundingBox] = {

case (TypeInfo(clazz, _), json) if clazz == classOf[InsideBoundingBox] =>
json match {
case JString(value) => InsideBoundingBox.StringValue(value)
case JArray(value) if value.forall(_.isInstanceOf[JArray]) =>
InsideBoundingBox.SeqOfSeqOfDouble(value.map(_.extract))
case _ => throw new MappingException("Can't convert " + json + " to InsideBoundingBox")
}
}

override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: InsideBoundingBox =>
value match {
case InsideBoundingBox.StringValue(value) => JString(value)
case InsideBoundingBox.SeqOfSeqOfDouble(value) => JArray(value.map(Extraction.decompose).toList)
}
}
}
2 changes: 2 additions & 0 deletions src/main/scala/algoliasearch/recommend/JsonSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ object JsonSupport {
FacetFiltersSerializer :+
HighlightResultSerializer :+
IgnorePluralsSerializer :+
InsideBoundingBoxSerializer :+
NumericFiltersSerializer :+
OptionalFiltersSerializer :+
OptionalWordsSerializer :+
ReRankingApplyFilterSerializer :+
RecommendationsHitSerializer :+
RecommendationsRequestSerializer :+
Expand Down
Loading

0 comments on commit 5bdc106

Please sign in to comment.