Skip to content

Commit 2a0eef2

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 58d3451 commit 2a0eef2

14 files changed

+617
-585
lines changed

algoliasearch/src/main/java/com/algolia/model/recommend/FallbackParams.java

Lines changed: 29 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class FallbackParams {
6060
private Integer minimumAroundRadius;
6161

6262
@JsonProperty("insideBoundingBox")
63-
private List<List<Double>> insideBoundingBox;
63+
private InsideBoundingBox insideBoundingBox;
6464

6565
@JsonProperty("insidePolygon")
6666
private List<List<Double>> insidePolygon;
@@ -152,6 +152,9 @@ public class FallbackParams {
152152
@JsonProperty("attributeForDistinct")
153153
private String attributeForDistinct;
154154

155+
@JsonProperty("maxFacetHits")
156+
private Integer maxFacetHits;
157+
155158
@JsonProperty("attributesToRetrieve")
156159
private List<String> attributesToRetrieve;
157160

@@ -222,7 +225,7 @@ public class FallbackParams {
222225
private Boolean advancedSyntax;
223226

224227
@JsonProperty("optionalWords")
225-
private List<String> optionalWords;
228+
private OptionalWords optionalWords;
226229

227230
@JsonProperty("disableExactOnAttributes")
228231
private List<String> disableExactOnAttributes;
@@ -248,9 +251,6 @@ public class FallbackParams {
248251
@JsonProperty("responseFields")
249252
private List<String> responseFields;
250253

251-
@JsonProperty("maxFacetHits")
252-
private Integer maxFacetHits;
253-
254254
@JsonProperty("maxValuesPerFacet")
255255
private Integer maxValuesPerFacet;
256256

@@ -500,28 +500,14 @@ public Integer getMinimumAroundRadius() {
500500
return minimumAroundRadius;
501501
}
502502

503-
public FallbackParams setInsideBoundingBox(List<List<Double>> insideBoundingBox) {
503+
public FallbackParams setInsideBoundingBox(InsideBoundingBox insideBoundingBox) {
504504
this.insideBoundingBox = insideBoundingBox;
505505
return this;
506506
}
507507

508-
public FallbackParams addInsideBoundingBox(List<Double> insideBoundingBoxItem) {
509-
if (this.insideBoundingBox == null) {
510-
this.insideBoundingBox = new ArrayList<>();
511-
}
512-
this.insideBoundingBox.add(insideBoundingBoxItem);
513-
return this;
514-
}
515-
516-
/**
517-
* Coordinates for a rectangular area in which to search. Each bounding box is defined by the two
518-
* opposite points of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1
519-
* long, p2 lat, p2 long]`. Provide multiple bounding boxes as nested arrays. For more
520-
* information, see [rectangular
521-
* area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas).
522-
*/
508+
/** Get insideBoundingBox */
523509
@javax.annotation.Nullable
524-
public List<List<Double>> getInsideBoundingBox() {
510+
public InsideBoundingBox getInsideBoundingBox() {
525511
return insideBoundingBox;
526512
}
527513

@@ -1120,6 +1106,21 @@ public String getAttributeForDistinct() {
11201106
return attributeForDistinct;
11211107
}
11221108

1109+
public FallbackParams setMaxFacetHits(Integer maxFacetHits) {
1110+
this.maxFacetHits = maxFacetHits;
1111+
return this;
1112+
}
1113+
1114+
/**
1115+
* Maximum number of facet values to return when [searching for facet
1116+
* values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
1117+
* maximum: 100
1118+
*/
1119+
@javax.annotation.Nullable
1120+
public Integer getMaxFacetHits() {
1121+
return maxFacetHits;
1122+
}
1123+
11231124
public FallbackParams setAttributesToRetrieve(List<String> attributesToRetrieve) {
11241125
this.attributesToRetrieve = attributesToRetrieve;
11251126
return this;
@@ -1507,38 +1508,14 @@ public Boolean getAdvancedSyntax() {
15071508
return advancedSyntax;
15081509
}
15091510

1510-
public FallbackParams setOptionalWords(List<String> optionalWords) {
1511+
public FallbackParams setOptionalWords(OptionalWords optionalWords) {
15111512
this.optionalWords = optionalWords;
15121513
return this;
15131514
}
15141515

1515-
public FallbackParams addOptionalWords(String optionalWordsItem) {
1516-
if (this.optionalWords == null) {
1517-
this.optionalWords = new ArrayList<>();
1518-
}
1519-
this.optionalWords.add(optionalWordsItem);
1520-
return this;
1521-
}
1522-
1523-
/**
1524-
* Words that should be considered optional when found in the query. By default, records must
1525-
* match all words in the search query to be included in the search results. Adding optional words
1526-
* can help to increase the number of search results by running an additional search query that
1527-
* doesn't include the optional words. For example, if the search query is \"action video\" and
1528-
* \"video\" is an optional word, the search engine runs two queries. One for \"action video\" and
1529-
* one for \"action\". Records that match all words are ranked higher. For a search query with 4
1530-
* or more words **and** all its words are optional, the number of matched words required for a
1531-
* record to be included in the search results increases for every 1,000 records: - If
1532-
* `optionalWords` has less than 10 words, the required number of matched words increases by 1:
1533-
* results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched words. - If
1534-
* `optionalWords` has 10 or more words, the number of required matched words increases by the
1535-
* number of optional words divided by 5 (rounded down). For example, with 18 optional words:
1536-
* results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 4 matched words. For more
1537-
* information, see [Optional
1538-
* words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words).
1539-
*/
1516+
/** Get optionalWords */
15401517
@javax.annotation.Nullable
1541-
public List<String> getOptionalWords() {
1518+
public OptionalWords getOptionalWords() {
15421519
return optionalWords;
15431520
}
15441521

@@ -1705,21 +1682,6 @@ public List<String> getResponseFields() {
17051682
return responseFields;
17061683
}
17071684

1708-
public FallbackParams setMaxFacetHits(Integer maxFacetHits) {
1709-
this.maxFacetHits = maxFacetHits;
1710-
return this;
1711-
}
1712-
1713-
/**
1714-
* Maximum number of facet values to return when [searching for facet
1715-
* values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values).
1716-
* maximum: 100
1717-
*/
1718-
@javax.annotation.Nullable
1719-
public Integer getMaxFacetHits() {
1720-
return maxFacetHits;
1721-
}
1722-
17231685
public FallbackParams setMaxValuesPerFacet(Integer maxValuesPerFacet) {
17241686
this.maxValuesPerFacet = maxValuesPerFacet;
17251687
return this;
@@ -1858,6 +1820,7 @@ public boolean equals(Object o) {
18581820
Objects.equals(this.userData, fallbackParams.userData) &&
18591821
Objects.equals(this.customNormalization, fallbackParams.customNormalization) &&
18601822
Objects.equals(this.attributeForDistinct, fallbackParams.attributeForDistinct) &&
1823+
Objects.equals(this.maxFacetHits, fallbackParams.maxFacetHits) &&
18611824
Objects.equals(this.attributesToRetrieve, fallbackParams.attributesToRetrieve) &&
18621825
Objects.equals(this.ranking, fallbackParams.ranking) &&
18631826
Objects.equals(this.relevancyStrictness, fallbackParams.relevancyStrictness) &&
@@ -1890,7 +1853,6 @@ public boolean equals(Object o) {
18901853
Objects.equals(this.replaceSynonymsInHighlight, fallbackParams.replaceSynonymsInHighlight) &&
18911854
Objects.equals(this.minProximity, fallbackParams.minProximity) &&
18921855
Objects.equals(this.responseFields, fallbackParams.responseFields) &&
1893-
Objects.equals(this.maxFacetHits, fallbackParams.maxFacetHits) &&
18941856
Objects.equals(this.maxValuesPerFacet, fallbackParams.maxValuesPerFacet) &&
18951857
Objects.equals(this.sortFacetValuesBy, fallbackParams.sortFacetValuesBy) &&
18961858
Objects.equals(this.attributeCriteriaComputedByMinProximity, fallbackParams.attributeCriteriaComputedByMinProximity) &&
@@ -1949,6 +1911,7 @@ public int hashCode() {
19491911
userData,
19501912
customNormalization,
19511913
attributeForDistinct,
1914+
maxFacetHits,
19521915
attributesToRetrieve,
19531916
ranking,
19541917
relevancyStrictness,
@@ -1981,7 +1944,6 @@ public int hashCode() {
19811944
replaceSynonymsInHighlight,
19821945
minProximity,
19831946
responseFields,
1984-
maxFacetHits,
19851947
maxValuesPerFacet,
19861948
sortFacetValuesBy,
19871949
attributeCriteriaComputedByMinProximity,
@@ -2041,6 +2003,7 @@ public String toString() {
20412003
sb.append(" userData: ").append(toIndentedString(userData)).append("\n");
20422004
sb.append(" customNormalization: ").append(toIndentedString(customNormalization)).append("\n");
20432005
sb.append(" attributeForDistinct: ").append(toIndentedString(attributeForDistinct)).append("\n");
2006+
sb.append(" maxFacetHits: ").append(toIndentedString(maxFacetHits)).append("\n");
20442007
sb.append(" attributesToRetrieve: ").append(toIndentedString(attributesToRetrieve)).append("\n");
20452008
sb.append(" ranking: ").append(toIndentedString(ranking)).append("\n");
20462009
sb.append(" relevancyStrictness: ").append(toIndentedString(relevancyStrictness)).append("\n");
@@ -2073,7 +2036,6 @@ public String toString() {
20732036
sb.append(" replaceSynonymsInHighlight: ").append(toIndentedString(replaceSynonymsInHighlight)).append("\n");
20742037
sb.append(" minProximity: ").append(toIndentedString(minProximity)).append("\n");
20752038
sb.append(" responseFields: ").append(toIndentedString(responseFields)).append("\n");
2076-
sb.append(" maxFacetHits: ").append(toIndentedString(maxFacetHits)).append("\n");
20772039
sb.append(" maxValuesPerFacet: ").append(toIndentedString(maxValuesPerFacet)).append("\n");
20782040
sb.append(" sortFacetValuesBy: ").append(toIndentedString(sortFacetValuesBy)).append("\n");
20792041
sb
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
2+
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
package com.algolia.model.recommend;
5+
6+
import com.algolia.exceptions.AlgoliaRuntimeException;
7+
import com.fasterxml.jackson.annotation.*;
8+
import com.fasterxml.jackson.core.*;
9+
import com.fasterxml.jackson.core.type.TypeReference;
10+
import com.fasterxml.jackson.databind.*;
11+
import com.fasterxml.jackson.databind.annotation.*;
12+
import java.io.IOException;
13+
import java.util.List;
14+
import java.util.logging.Logger;
15+
16+
/** InsideBoundingBox */
17+
@JsonDeserialize(using = InsideBoundingBox.Deserializer.class)
18+
public interface InsideBoundingBox {
19+
// InsideBoundingBox as String wrapper.
20+
static InsideBoundingBox of(String value) {
21+
return new StringWrapper(value);
22+
}
23+
24+
// InsideBoundingBox as List<List<Double>> wrapper.
25+
static InsideBoundingBox of(List<List<Double>> value) {
26+
return new ListOfListOfDoubleWrapper(value);
27+
}
28+
29+
// InsideBoundingBox as String wrapper.
30+
@JsonSerialize(using = StringWrapper.Serializer.class)
31+
class StringWrapper implements InsideBoundingBox {
32+
33+
private final String value;
34+
35+
StringWrapper(String value) {
36+
this.value = value;
37+
}
38+
39+
public String getValue() {
40+
return value;
41+
}
42+
43+
static class Serializer extends JsonSerializer<StringWrapper> {
44+
45+
@Override
46+
public void serialize(StringWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException {
47+
gen.writeObject(value.getValue());
48+
}
49+
}
50+
}
51+
52+
// InsideBoundingBox as List<List<Double>> wrapper.
53+
@JsonSerialize(using = ListOfListOfDoubleWrapper.Serializer.class)
54+
class ListOfListOfDoubleWrapper implements InsideBoundingBox {
55+
56+
private final List<List<Double>> value;
57+
58+
ListOfListOfDoubleWrapper(List<List<Double>> value) {
59+
this.value = value;
60+
}
61+
62+
public List<List<Double>> getValue() {
63+
return value;
64+
}
65+
66+
static class Serializer extends JsonSerializer<ListOfListOfDoubleWrapper> {
67+
68+
@Override
69+
public void serialize(ListOfListOfDoubleWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException {
70+
gen.writeObject(value.getValue());
71+
}
72+
}
73+
}
74+
75+
class Deserializer extends JsonDeserializer<InsideBoundingBox> {
76+
77+
private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());
78+
79+
@Override
80+
public InsideBoundingBox deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
81+
JsonNode tree = jp.readValueAsTree();
82+
// deserialize String
83+
if (tree.isTextual()) {
84+
try (JsonParser parser = tree.traverse(jp.getCodec())) {
85+
String value = parser.readValueAs(String.class);
86+
return new InsideBoundingBox.StringWrapper(value);
87+
} catch (Exception e) {
88+
// deserialization failed, continue
89+
LOGGER.finest("Failed to deserialize oneOf String (error: " + e.getMessage() + ") (type: String)");
90+
}
91+
}
92+
// deserialize List<List<Double>>
93+
if (tree.isArray()) {
94+
try (JsonParser parser = tree.traverse(jp.getCodec())) {
95+
List<List<Double>> value = parser.readValueAs(new TypeReference<List<List<Double>>>() {});
96+
return new InsideBoundingBox.ListOfListOfDoubleWrapper(value);
97+
} catch (Exception e) {
98+
// deserialization failed, continue
99+
LOGGER.finest("Failed to deserialize oneOf List<List<Double>> (error: " + e.getMessage() + ") (type: List<List<Double>>)");
100+
}
101+
}
102+
throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
103+
}
104+
105+
/** Handle deserialization of the 'null' value. */
106+
@Override
107+
public InsideBoundingBox getNullValue(DeserializationContext ctxt) throws JsonMappingException {
108+
return null;
109+
}
110+
}
111+
}

0 commit comments

Comments
 (0)