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 58d3451 commit 2a0eef2
Show file tree
Hide file tree
Showing 14 changed files with 617 additions and 585 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class FallbackParams {
private Integer minimumAroundRadius;

@JsonProperty("insideBoundingBox")
private List<List<Double>> insideBoundingBox;
private InsideBoundingBox insideBoundingBox;

@JsonProperty("insidePolygon")
private List<List<Double>> insidePolygon;
Expand Down Expand Up @@ -152,6 +152,9 @@ public class FallbackParams {
@JsonProperty("attributeForDistinct")
private String attributeForDistinct;

@JsonProperty("maxFacetHits")
private Integer maxFacetHits;

@JsonProperty("attributesToRetrieve")
private List<String> attributesToRetrieve;

Expand Down Expand Up @@ -222,7 +225,7 @@ public class FallbackParams {
private Boolean advancedSyntax;

@JsonProperty("optionalWords")
private List<String> optionalWords;
private OptionalWords optionalWords;

@JsonProperty("disableExactOnAttributes")
private List<String> disableExactOnAttributes;
Expand All @@ -248,9 +251,6 @@ public class FallbackParams {
@JsonProperty("responseFields")
private List<String> responseFields;

@JsonProperty("maxFacetHits")
private Integer maxFacetHits;

@JsonProperty("maxValuesPerFacet")
private Integer maxValuesPerFacet;

Expand Down Expand Up @@ -500,28 +500,14 @@ public Integer getMinimumAroundRadius() {
return minimumAroundRadius;
}

public FallbackParams setInsideBoundingBox(List<List<Double>> insideBoundingBox) {
public FallbackParams setInsideBoundingBox(InsideBoundingBox insideBoundingBox) {
this.insideBoundingBox = insideBoundingBox;
return this;
}

public FallbackParams addInsideBoundingBox(List<Double> insideBoundingBoxItem) {
if (this.insideBoundingBox == null) {
this.insideBoundingBox = new ArrayList<>();
}
this.insideBoundingBox.add(insideBoundingBoxItem);
return this;
}

/**
* 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).
*/
/** Get insideBoundingBox */
@javax.annotation.Nullable
public List<List<Double>> getInsideBoundingBox() {
public InsideBoundingBox getInsideBoundingBox() {
return insideBoundingBox;
}

Expand Down Expand Up @@ -1120,6 +1106,21 @@ public String getAttributeForDistinct() {
return attributeForDistinct;
}

public FallbackParams setMaxFacetHits(Integer maxFacetHits) {
this.maxFacetHits = maxFacetHits;
return this;
}

/**
* 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).
* maximum: 100
*/
@javax.annotation.Nullable
public Integer getMaxFacetHits() {
return maxFacetHits;
}

public FallbackParams setAttributesToRetrieve(List<String> attributesToRetrieve) {
this.attributesToRetrieve = attributesToRetrieve;
return this;
Expand Down Expand Up @@ -1507,38 +1508,14 @@ public Boolean getAdvancedSyntax() {
return advancedSyntax;
}

public FallbackParams setOptionalWords(List<String> optionalWords) {
public FallbackParams setOptionalWords(OptionalWords optionalWords) {
this.optionalWords = optionalWords;
return this;
}

public FallbackParams addOptionalWords(String optionalWordsItem) {
if (this.optionalWords == null) {
this.optionalWords = new ArrayList<>();
}
this.optionalWords.add(optionalWordsItem);
return this;
}

/**
* 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).
*/
/** Get optionalWords */
@javax.annotation.Nullable
public List<String> getOptionalWords() {
public OptionalWords getOptionalWords() {
return optionalWords;
}

Expand Down Expand Up @@ -1705,21 +1682,6 @@ public List<String> getResponseFields() {
return responseFields;
}

public FallbackParams setMaxFacetHits(Integer maxFacetHits) {
this.maxFacetHits = maxFacetHits;
return this;
}

/**
* 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).
* maximum: 100
*/
@javax.annotation.Nullable
public Integer getMaxFacetHits() {
return maxFacetHits;
}

public FallbackParams setMaxValuesPerFacet(Integer maxValuesPerFacet) {
this.maxValuesPerFacet = maxValuesPerFacet;
return this;
Expand Down Expand Up @@ -1858,6 +1820,7 @@ public boolean equals(Object o) {
Objects.equals(this.userData, fallbackParams.userData) &&
Objects.equals(this.customNormalization, fallbackParams.customNormalization) &&
Objects.equals(this.attributeForDistinct, fallbackParams.attributeForDistinct) &&
Objects.equals(this.maxFacetHits, fallbackParams.maxFacetHits) &&
Objects.equals(this.attributesToRetrieve, fallbackParams.attributesToRetrieve) &&
Objects.equals(this.ranking, fallbackParams.ranking) &&
Objects.equals(this.relevancyStrictness, fallbackParams.relevancyStrictness) &&
Expand Down Expand Up @@ -1890,7 +1853,6 @@ public boolean equals(Object o) {
Objects.equals(this.replaceSynonymsInHighlight, fallbackParams.replaceSynonymsInHighlight) &&
Objects.equals(this.minProximity, fallbackParams.minProximity) &&
Objects.equals(this.responseFields, fallbackParams.responseFields) &&
Objects.equals(this.maxFacetHits, fallbackParams.maxFacetHits) &&
Objects.equals(this.maxValuesPerFacet, fallbackParams.maxValuesPerFacet) &&
Objects.equals(this.sortFacetValuesBy, fallbackParams.sortFacetValuesBy) &&
Objects.equals(this.attributeCriteriaComputedByMinProximity, fallbackParams.attributeCriteriaComputedByMinProximity) &&
Expand Down Expand Up @@ -1949,6 +1911,7 @@ public int hashCode() {
userData,
customNormalization,
attributeForDistinct,
maxFacetHits,
attributesToRetrieve,
ranking,
relevancyStrictness,
Expand Down Expand Up @@ -1981,7 +1944,6 @@ public int hashCode() {
replaceSynonymsInHighlight,
minProximity,
responseFields,
maxFacetHits,
maxValuesPerFacet,
sortFacetValuesBy,
attributeCriteriaComputedByMinProximity,
Expand Down Expand Up @@ -2041,6 +2003,7 @@ public String toString() {
sb.append(" userData: ").append(toIndentedString(userData)).append("\n");
sb.append(" customNormalization: ").append(toIndentedString(customNormalization)).append("\n");
sb.append(" attributeForDistinct: ").append(toIndentedString(attributeForDistinct)).append("\n");
sb.append(" maxFacetHits: ").append(toIndentedString(maxFacetHits)).append("\n");
sb.append(" attributesToRetrieve: ").append(toIndentedString(attributesToRetrieve)).append("\n");
sb.append(" ranking: ").append(toIndentedString(ranking)).append("\n");
sb.append(" relevancyStrictness: ").append(toIndentedString(relevancyStrictness)).append("\n");
Expand Down Expand Up @@ -2073,7 +2036,6 @@ public String toString() {
sb.append(" replaceSynonymsInHighlight: ").append(toIndentedString(replaceSynonymsInHighlight)).append("\n");
sb.append(" minProximity: ").append(toIndentedString(minProximity)).append("\n");
sb.append(" responseFields: ").append(toIndentedString(responseFields)).append("\n");
sb.append(" maxFacetHits: ").append(toIndentedString(maxFacetHits)).append("\n");
sb.append(" maxValuesPerFacet: ").append(toIndentedString(maxValuesPerFacet)).append("\n");
sb.append(" sortFacetValuesBy: ").append(toIndentedString(sortFacetValuesBy)).append("\n");
sb
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// 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.model.recommend;

import com.algolia.exceptions.AlgoliaRuntimeException;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.*;
import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;

/** InsideBoundingBox */
@JsonDeserialize(using = InsideBoundingBox.Deserializer.class)
public interface InsideBoundingBox {
// InsideBoundingBox as String wrapper.
static InsideBoundingBox of(String value) {
return new StringWrapper(value);
}

// InsideBoundingBox as List<List<Double>> wrapper.
static InsideBoundingBox of(List<List<Double>> value) {
return new ListOfListOfDoubleWrapper(value);
}

// InsideBoundingBox as String wrapper.
@JsonSerialize(using = StringWrapper.Serializer.class)
class StringWrapper implements InsideBoundingBox {

private final String value;

StringWrapper(String value) {
this.value = value;
}

public String getValue() {
return value;
}

static class Serializer extends JsonSerializer<StringWrapper> {

@Override
public void serialize(StringWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeObject(value.getValue());
}
}
}

// InsideBoundingBox as List<List<Double>> wrapper.
@JsonSerialize(using = ListOfListOfDoubleWrapper.Serializer.class)
class ListOfListOfDoubleWrapper implements InsideBoundingBox {

private final List<List<Double>> value;

ListOfListOfDoubleWrapper(List<List<Double>> value) {
this.value = value;
}

public List<List<Double>> getValue() {
return value;
}

static class Serializer extends JsonSerializer<ListOfListOfDoubleWrapper> {

@Override
public void serialize(ListOfListOfDoubleWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeObject(value.getValue());
}
}
}

class Deserializer extends JsonDeserializer<InsideBoundingBox> {

private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());

@Override
public InsideBoundingBox deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode tree = jp.readValueAsTree();
// deserialize String
if (tree.isTextual()) {
try (JsonParser parser = tree.traverse(jp.getCodec())) {
String value = parser.readValueAs(String.class);
return new InsideBoundingBox.StringWrapper(value);
} catch (Exception e) {
// deserialization failed, continue
LOGGER.finest("Failed to deserialize oneOf String (error: " + e.getMessage() + ") (type: String)");
}
}
// deserialize List<List<Double>>
if (tree.isArray()) {
try (JsonParser parser = tree.traverse(jp.getCodec())) {
List<List<Double>> value = parser.readValueAs(new TypeReference<List<List<Double>>>() {});
return new InsideBoundingBox.ListOfListOfDoubleWrapper(value);
} catch (Exception e) {
// deserialization failed, continue
LOGGER.finest("Failed to deserialize oneOf List<List<Double>> (error: " + e.getMessage() + ") (type: List<List<Double>>)");
}
}
throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
}

/** Handle deserialization of the 'null' value. */
@Override
public InsideBoundingBox getNullValue(DeserializationContext ctxt) throws JsonMappingException {
return null;
}
}
}
Loading

0 comments on commit 2a0eef2

Please sign in to comment.