Skip to content

Commit 5bdc106

Browse files
algolia-botmillotp
andcommitted
fix(specs): make the searchParams compatible with v4 [skip-bc] (generated)
algolia/api-clients-automation#4108 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 92cb2bb commit 5bdc106

24 files changed

+347
-284
lines changed

src/main/scala/algoliasearch/recommend/BaseIndexSettings.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ import algoliasearch.recommend.SupportedLanguage._
135135
* `distinct` search parameter to control how many items per group are included in the search results. If you want to
136136
* use the same attribute also for faceting, use the `afterDistinct` modifier of the `attributesForFaceting` setting.
137137
* This applies faceting _after_ deduplication, which will result in accurate facet counts.
138+
* @param maxFacetHits
139+
* Maximum number of facet values to return when [searching for facet
140+
* values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
138141
*/
139142
case class BaseIndexSettings(
140143
attributesForFaceting: Option[Seq[String]] = scala.None,
@@ -153,5 +156,6 @@ case class BaseIndexSettings(
153156
searchableAttributes: Option[Seq[String]] = scala.None,
154157
userData: Option[Any] = scala.None,
155158
customNormalization: Option[Map[String, Map[String, String]]] = scala.None,
156-
attributeForDistinct: Option[String] = scala.None
159+
attributeForDistinct: Option[String] = scala.None,
160+
maxFacetHits: Option[Int] = scala.None
157161
)

src/main/scala/algoliasearch/recommend/BaseRecommendIndexSettings.scala

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,6 @@ import algoliasearch.recommend.SupportedLanguage._
122122
* @param advancedSyntax
123123
* Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures`
124124
* parameter to control which feature is supported.
125-
* @param optionalWords
126-
* Words that should be considered optional when found in the query. By default, records must match all words in the
127-
* search query to be included in the search results. Adding optional words can help to increase the number of search
128-
* results by running an additional search query that doesn't include the optional words. For example, if the search
129-
* query is \"action video\" and \"video\" is an optional word, the search engine runs two queries. One for \"action
130-
* video\" and one for \"action\". Records that match all words are ranked higher. For a search query with 4 or more
131-
* words **and** all its words are optional, the number of matched words required for a record to be included in the
132-
* search results increases for every 1,000 records: - If `optionalWords` has less than 10 words, the required number
133-
* of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched
134-
* words. - If `optionalWords` has 10 or more words, the number of required matched words increases by the number of
135-
* optional words divided by 5 (rounded down). For example, with 18 optional words: results 1 to 1,000 require 1
136-
* matched word, results 1,001 to 2000 need 4 matched words. For more information, see [Optional
137-
* words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words).
138125
* @param disableExactOnAttributes
139126
* Searchable attributes for which you want to [turn off the Exact ranking
140127
* 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).
@@ -174,9 +161,6 @@ import algoliasearch.recommend.SupportedLanguage._
174161
* these properties: `message`, `warning`, `cursor`, `serverUsed`, `indexUsed`, `abTestVariantID`, `parsedQuery`, or
175162
* any property triggered by the `getRankingInfo` parameter. Don't exclude properties that you might need in your
176163
* search UI.
177-
* @param maxFacetHits
178-
* Maximum number of facet values to return when [searching for facet
179-
* values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
180164
* @param maxValuesPerFacet
181165
* Maximum number of facet values to return for each facet.
182166
* @param sortFacetValuesBy
@@ -218,7 +202,7 @@ case class BaseRecommendIndexSettings(
218202
queryType: Option[QueryType] = scala.None,
219203
removeWordsIfNoResults: Option[RemoveWordsIfNoResults] = scala.None,
220204
advancedSyntax: Option[Boolean] = scala.None,
221-
optionalWords: Option[Seq[String]] = scala.None,
205+
optionalWords: Option[OptionalWords] = scala.None,
222206
disableExactOnAttributes: Option[Seq[String]] = scala.None,
223207
exactOnSingleWordQuery: Option[ExactOnSingleWordQuery] = scala.None,
224208
alternativesAsExact: Option[Seq[AlternativesAsExact]] = scala.None,
@@ -227,7 +211,6 @@ case class BaseRecommendIndexSettings(
227211
replaceSynonymsInHighlight: Option[Boolean] = scala.None,
228212
minProximity: Option[Int] = scala.None,
229213
responseFields: Option[Seq[String]] = scala.None,
230-
maxFacetHits: Option[Int] = scala.None,
231214
maxValuesPerFacet: Option[Int] = scala.None,
232215
sortFacetValuesBy: Option[String] = scala.None,
233216
attributeCriteriaComputedByMinProximity: Option[Boolean] = scala.None,

src/main/scala/algoliasearch/recommend/BaseRecommendSearchParams.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ import algoliasearch.recommend.SupportedLanguage._
7777
* Whether to obtain the coordinates from the request's IP address.
7878
* @param minimumAroundRadius
7979
* Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.
80-
* @param insideBoundingBox
81-
* Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points of
82-
* its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide multiple
83-
* bounding boxes as nested arrays. For more information, see [rectangular
84-
* area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas).
8580
* @param insidePolygon
8681
* Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented
8782
* by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering
@@ -138,7 +133,7 @@ case class BaseRecommendSearchParams(
138133
aroundRadius: Option[AroundRadius] = scala.None,
139134
aroundPrecision: Option[AroundPrecision] = scala.None,
140135
minimumAroundRadius: Option[Int] = scala.None,
141-
insideBoundingBox: Option[Seq[Seq[Double]]] = scala.None,
136+
insideBoundingBox: Option[InsideBoundingBox] = scala.None,
142137
insidePolygon: Option[Seq[Seq[Double]]] = scala.None,
143138
naturalLanguages: Option[Seq[SupportedLanguage]] = scala.None,
144139
ruleContexts: Option[Seq[String]] = scala.None,

src/main/scala/algoliasearch/recommend/FallbackParams.scala

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ import algoliasearch.recommend.SupportedLanguage._
8282
* Whether to obtain the coordinates from the request's IP address.
8383
* @param minimumAroundRadius
8484
* Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.
85-
* @param insideBoundingBox
86-
* Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points of
87-
* its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide multiple
88-
* bounding boxes as nested arrays. For more information, see [rectangular
89-
* area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas).
9085
* @param insidePolygon
9186
* Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented
9287
* by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering
@@ -230,6 +225,9 @@ import algoliasearch.recommend.SupportedLanguage._
230225
* `distinct` search parameter to control how many items per group are included in the search results. If you want to
231226
* use the same attribute also for faceting, use the `afterDistinct` modifier of the `attributesForFaceting` setting.
232227
* This applies faceting _after_ deduplication, which will result in accurate facet counts.
228+
* @param maxFacetHits
229+
* Maximum number of facet values to return when [searching for facet
230+
* values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
233231
* @param attributesToRetrieve
234232
* Attributes to include in the API response. To reduce the size of your response, you can retrieve only some of the
235233
* attributes. Attribute names are case-sensitive. - `*` retrieves all attributes, except attributes included in the
@@ -314,19 +312,6 @@ import algoliasearch.recommend.SupportedLanguage._
314312
* @param advancedSyntax
315313
* Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures`
316314
* parameter to control which feature is supported.
317-
* @param optionalWords
318-
* Words that should be considered optional when found in the query. By default, records must match all words in the
319-
* search query to be included in the search results. Adding optional words can help to increase the number of search
320-
* results by running an additional search query that doesn't include the optional words. For example, if the search
321-
* query is \"action video\" and \"video\" is an optional word, the search engine runs two queries. One for \"action
322-
* video\" and one for \"action\". Records that match all words are ranked higher. For a search query with 4 or more
323-
* words **and** all its words are optional, the number of matched words required for a record to be included in the
324-
* search results increases for every 1,000 records: - If `optionalWords` has less than 10 words, the required number
325-
* of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched
326-
* words. - If `optionalWords` has 10 or more words, the number of required matched words increases by the number of
327-
* optional words divided by 5 (rounded down). For example, with 18 optional words: results 1 to 1,000 require 1
328-
* matched word, results 1,001 to 2000 need 4 matched words. For more information, see [Optional
329-
* words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words).
330315
* @param disableExactOnAttributes
331316
* Searchable attributes for which you want to [turn off the Exact ranking
332317
* 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).
@@ -366,9 +351,6 @@ import algoliasearch.recommend.SupportedLanguage._
366351
* these properties: `message`, `warning`, `cursor`, `serverUsed`, `indexUsed`, `abTestVariantID`, `parsedQuery`, or
367352
* any property triggered by the `getRankingInfo` parameter. Don't exclude properties that you might need in your
368353
* search UI.
369-
* @param maxFacetHits
370-
* Maximum number of facet values to return when [searching for facet
371-
* values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
372354
* @param maxValuesPerFacet
373355
* Maximum number of facet values to return for each facet.
374356
* @param sortFacetValuesBy
@@ -402,7 +384,7 @@ case class FallbackParams(
402384
aroundRadius: Option[AroundRadius] = scala.None,
403385
aroundPrecision: Option[AroundPrecision] = scala.None,
404386
minimumAroundRadius: Option[Int] = scala.None,
405-
insideBoundingBox: Option[Seq[Seq[Double]]] = scala.None,
387+
insideBoundingBox: Option[InsideBoundingBox] = scala.None,
406388
insidePolygon: Option[Seq[Seq[Double]]] = scala.None,
407389
naturalLanguages: Option[Seq[SupportedLanguage]] = scala.None,
408390
ruleContexts: Option[Seq[String]] = scala.None,
@@ -433,6 +415,7 @@ case class FallbackParams(
433415
userData: Option[Any] = scala.None,
434416
customNormalization: Option[Map[String, Map[String, String]]] = scala.None,
435417
attributeForDistinct: Option[String] = scala.None,
418+
maxFacetHits: Option[Int] = scala.None,
436419
attributesToRetrieve: Option[Seq[String]] = scala.None,
437420
ranking: Option[Seq[String]] = scala.None,
438421
relevancyStrictness: Option[Int] = scala.None,
@@ -456,7 +439,7 @@ case class FallbackParams(
456439
queryType: Option[QueryType] = scala.None,
457440
removeWordsIfNoResults: Option[RemoveWordsIfNoResults] = scala.None,
458441
advancedSyntax: Option[Boolean] = scala.None,
459-
optionalWords: Option[Seq[String]] = scala.None,
442+
optionalWords: Option[OptionalWords] = scala.None,
460443
disableExactOnAttributes: Option[Seq[String]] = scala.None,
461444
exactOnSingleWordQuery: Option[ExactOnSingleWordQuery] = scala.None,
462445
alternativesAsExact: Option[Seq[AlternativesAsExact]] = scala.None,
@@ -465,7 +448,6 @@ case class FallbackParams(
465448
replaceSynonymsInHighlight: Option[Boolean] = scala.None,
466449
minProximity: Option[Int] = scala.None,
467450
responseFields: Option[Seq[String]] = scala.None,
468-
maxFacetHits: Option[Int] = scala.None,
469451
maxValuesPerFacet: Option[Int] = scala.None,
470452
sortFacetValuesBy: Option[String] = scala.None,
471453
attributeCriteriaComputedByMinProximity: Option[Boolean] = scala.None,
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/** Recommend API The Recommend API lets you retrieve recommendations from one of Algolia's AI recommendation models
2+
* that you previously trained on your data. ## Client libraries Use Algolia's API clients and libraries to reliably
3+
* integrate Algolia's APIs with your apps. The official API clients are covered by Algolia's [Service Level
4+
* Agreement](https://www.algolia.com/policies/sla/). See: [Algolia's
5+
* ecosystem](https://www.algolia.com/doc/guides/getting-started/how-algolia-works/in-depth/ecosystem/) ## Base URLs
6+
* The base URLs for requests to the Recommend API are: - `https://{APPLICATION_ID}.algolia.net` -
7+
* `https://{APPLICATION_ID}-dsn.algolia.net`. If your subscription includes a [Distributed Search
8+
* Network](https://dashboard.algolia.com/infra), this ensures that requests are sent to servers closest to users. Both
9+
* URLs provide high availability by distributing requests with load balancing. **All requests must use HTTPS.** ##
10+
* Retry strategy To guarantee a high availability, implement a retry strategy for all API requests using the URLs of
11+
* your servers as fallbacks: - `https://{APPLICATION_ID}-1.algolianet.com` -
12+
* `https://{APPLICATION_ID}-2.algolianet.com` - `https://{APPLICATION_ID}-3.algolianet.com` These URLs use a different
13+
* DNS provider than the primary URLs. You should randomize this list to ensure an even load across the three servers.
14+
* All Algolia API clients implement this retry strategy. ## Authentication To authenticate your API requests, add
15+
* these headers: - `x-algolia-application-id`. Your Algolia application ID. - `x-algolia-api-key`. An API key with the
16+
* necessary permissions to make the request. The required access control list (ACL) to make a request is listed in
17+
* each endpoint's reference. You can find your application ID and API key in the [Algolia
18+
* dashboard](https://dashboard.algolia.com/account). ## Request format Request bodies must be JSON objects. ##
19+
* Response status and errors The Recommend API returns JSON responses. Since JSON doesn't guarantee any specific
20+
* ordering, don't rely on the order of attributes in the API response. Successful responses return a `2xx` status.
21+
* Client errors return a `4xx` status. Server errors are indicated by a `5xx` status. Error responses have a `message`
22+
* property with more information. ## Version The current version of the Recommend API is version 1, as indicated by
23+
* the `/1/` in each endpoint's URL.
24+
*
25+
* The version of the OpenAPI document: 1.0.0
26+
*
27+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
28+
* https://openapi-generator.tech Do not edit the class manually.
29+
*/
30+
package algoliasearch.recommend
31+
32+
import org.json4s._
33+
34+
/** InsideBoundingBox
35+
*/
36+
sealed trait InsideBoundingBox
37+
38+
object InsideBoundingBox {
39+
40+
case class StringValue(value: String) extends InsideBoundingBox
41+
case class SeqOfSeqOfDouble(value: Seq[Seq[Double]]) extends InsideBoundingBox
42+
43+
def apply(value: String): InsideBoundingBox = {
44+
InsideBoundingBox.StringValue(value)
45+
}
46+
def apply(value: Seq[Seq[Double]]): InsideBoundingBox = {
47+
InsideBoundingBox.SeqOfSeqOfDouble(value)
48+
}
49+
50+
}
51+
52+
object InsideBoundingBoxSerializer extends Serializer[InsideBoundingBox] {
53+
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), InsideBoundingBox] = {
54+
55+
case (TypeInfo(clazz, _), json) if clazz == classOf[InsideBoundingBox] =>
56+
json match {
57+
case JString(value) => InsideBoundingBox.StringValue(value)
58+
case JArray(value) if value.forall(_.isInstanceOf[JArray]) =>
59+
InsideBoundingBox.SeqOfSeqOfDouble(value.map(_.extract))
60+
case _ => throw new MappingException("Can't convert " + json + " to InsideBoundingBox")
61+
}
62+
}
63+
64+
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: InsideBoundingBox =>
65+
value match {
66+
case InsideBoundingBox.StringValue(value) => JString(value)
67+
case InsideBoundingBox.SeqOfSeqOfDouble(value) => JArray(value.map(Extraction.decompose).toList)
68+
}
69+
}
70+
}

src/main/scala/algoliasearch/recommend/JsonSupport.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ object JsonSupport {
6060
FacetFiltersSerializer :+
6161
HighlightResultSerializer :+
6262
IgnorePluralsSerializer :+
63+
InsideBoundingBoxSerializer :+
6364
NumericFiltersSerializer :+
6465
OptionalFiltersSerializer :+
66+
OptionalWordsSerializer :+
6567
ReRankingApplyFilterSerializer :+
6668
RecommendationsHitSerializer :+
6769
RecommendationsRequestSerializer :+

0 commit comments

Comments
 (0)