From ae85461a4f31ad11e76139b1c0257d94756183ec Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Fri, 15 Nov 2024 14:47:20 +0000 Subject: [PATCH] fix(specs): make the searchParams compatible with v4 [skip-bc] (generated) https://github.com/algolia/api-clients-automation/pull/4108 Co-authored-by: algolia-bot Co-authored-by: Pierre Millot --- .../recommend/models/fallback_params.py | 24 ++-- .../recommend/models/inside_bounding_box.py | 110 ++++++++++++++++++ .../recommend/models/optional_words.py | 110 ++++++++++++++++++ .../models/recommend_search_params.py | 24 ++-- .../search/models/browse_params_object.py | 21 ++-- .../search/models/consequence_params.py | 21 ++-- .../search/models/delete_by_params.py | 9 +- algoliasearch/search/models/index_settings.py | 15 ++- .../search/models/inside_bounding_box.py | 110 ++++++++++++++++++ algoliasearch/search/models/optional_words.py | 110 ++++++++++++++++++ .../search/models/search_for_facets.py | 24 ++-- .../search/models/search_for_hits.py | 21 ++-- .../search/models/search_params_object.py | 21 ++-- .../search/models/settings_response.py | 15 ++- 14 files changed, 574 insertions(+), 61 deletions(-) create mode 100644 algoliasearch/recommend/models/inside_bounding_box.py create mode 100644 algoliasearch/recommend/models/optional_words.py create mode 100644 algoliasearch/search/models/inside_bounding_box.py create mode 100644 algoliasearch/search/models/optional_words.py diff --git a/algoliasearch/recommend/models/fallback_params.py b/algoliasearch/recommend/models/fallback_params.py index f7fae5d89..4552fe7df 100644 --- a/algoliasearch/recommend/models/fallback_params.py +++ b/algoliasearch/recommend/models/fallback_params.py @@ -30,8 +30,10 @@ ) from algoliasearch.recommend.models.facet_filters import FacetFilters from algoliasearch.recommend.models.ignore_plurals import IgnorePlurals +from algoliasearch.recommend.models.inside_bounding_box import InsideBoundingBox from algoliasearch.recommend.models.numeric_filters import NumericFilters from algoliasearch.recommend.models.optional_filters import OptionalFilters +from algoliasearch.recommend.models.optional_words import OptionalWords from algoliasearch.recommend.models.query_type import QueryType from algoliasearch.recommend.models.re_ranking_apply_filter import ReRankingApplyFilter from algoliasearch.recommend.models.remove_stop_words import RemoveStopWords @@ -90,6 +92,7 @@ "user_data": "userData", "custom_normalization": "customNormalization", "attribute_for_distinct": "attributeForDistinct", + "max_facet_hits": "maxFacetHits", "attributes_to_retrieve": "attributesToRetrieve", "ranking": "ranking", "relevancy_strictness": "relevancyStrictness", @@ -122,7 +125,6 @@ "replace_synonyms_in_highlight": "replaceSynonymsInHighlight", "min_proximity": "minProximity", "response_fields": "responseFields", - "max_facet_hits": "maxFacetHits", "max_values_per_facet": "maxValuesPerFacet", "sort_facet_values_by": "sortFacetValuesBy", "attribute_criteria_computed_by_min_proximity": "attributeCriteriaComputedByMinProximity", @@ -165,8 +167,7 @@ class FallbackParams(BaseModel): around_precision: Optional[AroundPrecision] = None minimum_around_radius: Optional[int] = None """ Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. """ - inside_bounding_box: Optional[List[List[float]]] = None - """ 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). """ + inside_bounding_box: Optional[InsideBoundingBox] = None inside_polygon: Optional[List[List[float]]] = None """ 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`. """ natural_languages: Optional[List[SupportedLanguage]] = None @@ -227,6 +228,8 @@ class FallbackParams(BaseModel): """ Characters and their normalized replacements. This overrides Algolia's default [normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/). """ attribute_for_distinct: Optional[str] = None """ Attribute that should be used to establish groups of results. Attribute names are case-sensitive. All records with the same value for this attribute are considered a group. You can combine `attributeForDistinct` with the `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. """ + max_facet_hits: Optional[int] = None + """ 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). """ attributes_to_retrieve: Optional[List[str]] = None """ 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 `customRanking` and `unretrievableAttributes` settings. - To retrieve all attributes except a specific one, prefix the attribute with a dash and combine it with the `*`: `[\"*\", \"-ATTRIBUTE\"]`. - The `objectID` attribute is always included. """ ranking: Optional[List[str]] = None @@ -268,8 +271,7 @@ class FallbackParams(BaseModel): remove_words_if_no_results: Optional[RemoveWordsIfNoResults] = None advanced_syntax: Optional[bool] = None """ Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. """ - optional_words: Optional[List[str]] = None - """ 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). """ + optional_words: Optional[OptionalWords] = None disable_exact_on_attributes: Optional[List[str]] = None """ 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. """ exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = None @@ -284,8 +286,6 @@ class FallbackParams(BaseModel): """ 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. """ response_fields: Optional[List[str]] = None """ 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. """ - max_facet_hits: Optional[int] = None - """ 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). """ max_values_per_facet: Optional[int] = None """ Maximum number of facet values to return for each facet. """ sort_facet_values_by: Optional[str] = None @@ -360,6 +360,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("aroundPrecision") is not None else None ) + obj["insideBoundingBox"] = ( + InsideBoundingBox.from_dict(obj["insideBoundingBox"]) + if obj.get("insideBoundingBox") is not None + else None + ) obj["naturalLanguages"] = obj.get("naturalLanguages") obj["indexLanguages"] = obj.get("indexLanguages") obj["typoTolerance"] = ( @@ -380,6 +385,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: obj["queryLanguages"] = obj.get("queryLanguages") obj["queryType"] = obj.get("queryType") obj["removeWordsIfNoResults"] = obj.get("removeWordsIfNoResults") + obj["optionalWords"] = ( + OptionalWords.from_dict(obj["optionalWords"]) + if obj.get("optionalWords") is not None + else None + ) obj["exactOnSingleWordQuery"] = obj.get("exactOnSingleWordQuery") obj["alternativesAsExact"] = obj.get("alternativesAsExact") obj["advancedSyntaxFeatures"] = obj.get("advancedSyntaxFeatures") diff --git a/algoliasearch/recommend/models/inside_bounding_box.py b/algoliasearch/recommend/models/inside_bounding_box.py new file mode 100644 index 000000000..5c2edc010 --- /dev/null +++ b/algoliasearch/recommend/models/inside_bounding_box.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" +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. +""" + +from __future__ import annotations + +from json import dumps, loads +from sys import version_info +from typing import Any, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, Field, ValidationError, model_serializer + +if version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + + +class InsideBoundingBox(BaseModel): + """ + InsideBoundingBox + """ + + oneof_schema_1_validator: Optional[str] = Field(default=None) + + oneof_schema_2_validator: Optional[List[List[float]]] = Field(default=None) + """ 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). """ + actual_instance: Union[List[List[float]], str, None] = None + one_of_schemas: Set[str] = {"List[List[float]]", "str"} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError( + "If a position argument is used, only 1 is allowed to set `actual_instance`" + ) + if kwargs: + raise ValueError( + "If a position argument is used, keyword arguments cannot be used." + ) + super().__init__(actual_instance=args[0]) # pyright: ignore + else: + super().__init__(**kwargs) + + @model_serializer + def unwrap_actual_instance(self) -> Union[List[List[float]], str, Self, None]: + """ + Unwraps the `actual_instance` when calling the `to_json` method. + """ + return self.actual_instance if hasattr(self, "actual_instance") else self + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + """Create an instance of InsideBoundingBox from a JSON string""" + return cls.from_json(dumps(obj)) + + @classmethod + def from_json(cls, json_str: Optional[str]) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + if json_str is None: + return instance + + error_messages = [] + + try: + instance.oneof_schema_1_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_1_validator + + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + try: + instance.oneof_schema_2_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_2_validator + + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + raise ValueError( + "No match found when deserializing the JSON string into InsideBoundingBox with oneOf schemas: List[List[float]], str. Details: " + + ", ".join(error_messages) + ) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable( + self.actual_instance.to_json # pyright: ignore + ): + return self.actual_instance.to_json() # pyright: ignore + else: + return dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], List[List[float]], str]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable( + self.actual_instance.to_dict # pyright: ignore + ): + return self.actual_instance.to_dict() # pyright: ignore + else: + return self.actual_instance # pyright: ignore diff --git a/algoliasearch/recommend/models/optional_words.py b/algoliasearch/recommend/models/optional_words.py new file mode 100644 index 000000000..e19f73dd9 --- /dev/null +++ b/algoliasearch/recommend/models/optional_words.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" +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. +""" + +from __future__ import annotations + +from json import dumps, loads +from sys import version_info +from typing import Any, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, Field, ValidationError, model_serializer + +if version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + + +class OptionalWords(BaseModel): + """ + OptionalWords + """ + + oneof_schema_1_validator: Optional[str] = Field(default=None) + + oneof_schema_2_validator: Optional[List[str]] = Field(default=None) + """ 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). """ + actual_instance: Union[List[str], str, None] = None + one_of_schemas: Set[str] = {"List[str]", "str"} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError( + "If a position argument is used, only 1 is allowed to set `actual_instance`" + ) + if kwargs: + raise ValueError( + "If a position argument is used, keyword arguments cannot be used." + ) + super().__init__(actual_instance=args[0]) # pyright: ignore + else: + super().__init__(**kwargs) + + @model_serializer + def unwrap_actual_instance(self) -> Union[List[str], str, Self, None]: + """ + Unwraps the `actual_instance` when calling the `to_json` method. + """ + return self.actual_instance if hasattr(self, "actual_instance") else self + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + """Create an instance of OptionalWords from a JSON string""" + return cls.from_json(dumps(obj)) + + @classmethod + def from_json(cls, json_str: Optional[str]) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + if json_str is None: + return instance + + error_messages = [] + + try: + instance.oneof_schema_1_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_1_validator + + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + try: + instance.oneof_schema_2_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_2_validator + + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + raise ValueError( + "No match found when deserializing the JSON string into OptionalWords with oneOf schemas: List[str], str. Details: " + + ", ".join(error_messages) + ) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable( + self.actual_instance.to_json # pyright: ignore + ): + return self.actual_instance.to_json() # pyright: ignore + else: + return dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], List[str], str]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable( + self.actual_instance.to_dict # pyright: ignore + ): + return self.actual_instance.to_dict() # pyright: ignore + else: + return self.actual_instance # pyright: ignore diff --git a/algoliasearch/recommend/models/recommend_search_params.py b/algoliasearch/recommend/models/recommend_search_params.py index ccd6eb789..5c36fe326 100644 --- a/algoliasearch/recommend/models/recommend_search_params.py +++ b/algoliasearch/recommend/models/recommend_search_params.py @@ -30,8 +30,10 @@ ) from algoliasearch.recommend.models.facet_filters import FacetFilters from algoliasearch.recommend.models.ignore_plurals import IgnorePlurals +from algoliasearch.recommend.models.inside_bounding_box import InsideBoundingBox from algoliasearch.recommend.models.numeric_filters import NumericFilters from algoliasearch.recommend.models.optional_filters import OptionalFilters +from algoliasearch.recommend.models.optional_words import OptionalWords from algoliasearch.recommend.models.query_type import QueryType from algoliasearch.recommend.models.re_ranking_apply_filter import ReRankingApplyFilter from algoliasearch.recommend.models.remove_stop_words import RemoveStopWords @@ -90,6 +92,7 @@ "user_data": "userData", "custom_normalization": "customNormalization", "attribute_for_distinct": "attributeForDistinct", + "max_facet_hits": "maxFacetHits", "attributes_to_retrieve": "attributesToRetrieve", "ranking": "ranking", "relevancy_strictness": "relevancyStrictness", @@ -122,7 +125,6 @@ "replace_synonyms_in_highlight": "replaceSynonymsInHighlight", "min_proximity": "minProximity", "response_fields": "responseFields", - "max_facet_hits": "maxFacetHits", "max_values_per_facet": "maxValuesPerFacet", "sort_facet_values_by": "sortFacetValuesBy", "attribute_criteria_computed_by_min_proximity": "attributeCriteriaComputedByMinProximity", @@ -165,8 +167,7 @@ class RecommendSearchParams(BaseModel): around_precision: Optional[AroundPrecision] = None minimum_around_radius: Optional[int] = None """ Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. """ - inside_bounding_box: Optional[List[List[float]]] = None - """ 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). """ + inside_bounding_box: Optional[InsideBoundingBox] = None inside_polygon: Optional[List[List[float]]] = None """ 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`. """ natural_languages: Optional[List[SupportedLanguage]] = None @@ -227,6 +228,8 @@ class RecommendSearchParams(BaseModel): """ Characters and their normalized replacements. This overrides Algolia's default [normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/). """ attribute_for_distinct: Optional[str] = None """ Attribute that should be used to establish groups of results. Attribute names are case-sensitive. All records with the same value for this attribute are considered a group. You can combine `attributeForDistinct` with the `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. """ + max_facet_hits: Optional[int] = None + """ 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). """ attributes_to_retrieve: Optional[List[str]] = None """ 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 `customRanking` and `unretrievableAttributes` settings. - To retrieve all attributes except a specific one, prefix the attribute with a dash and combine it with the `*`: `[\"*\", \"-ATTRIBUTE\"]`. - The `objectID` attribute is always included. """ ranking: Optional[List[str]] = None @@ -268,8 +271,7 @@ class RecommendSearchParams(BaseModel): remove_words_if_no_results: Optional[RemoveWordsIfNoResults] = None advanced_syntax: Optional[bool] = None """ Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. """ - optional_words: Optional[List[str]] = None - """ 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). """ + optional_words: Optional[OptionalWords] = None disable_exact_on_attributes: Optional[List[str]] = None """ 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. """ exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = None @@ -284,8 +286,6 @@ class RecommendSearchParams(BaseModel): """ 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. """ response_fields: Optional[List[str]] = None """ 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. """ - max_facet_hits: Optional[int] = None - """ 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). """ max_values_per_facet: Optional[int] = None """ Maximum number of facet values to return for each facet. """ sort_facet_values_by: Optional[str] = None @@ -360,6 +360,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("aroundPrecision") is not None else None ) + obj["insideBoundingBox"] = ( + InsideBoundingBox.from_dict(obj["insideBoundingBox"]) + if obj.get("insideBoundingBox") is not None + else None + ) obj["naturalLanguages"] = obj.get("naturalLanguages") obj["indexLanguages"] = obj.get("indexLanguages") obj["typoTolerance"] = ( @@ -380,6 +385,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: obj["queryLanguages"] = obj.get("queryLanguages") obj["queryType"] = obj.get("queryType") obj["removeWordsIfNoResults"] = obj.get("removeWordsIfNoResults") + obj["optionalWords"] = ( + OptionalWords.from_dict(obj["optionalWords"]) + if obj.get("optionalWords") is not None + else None + ) obj["exactOnSingleWordQuery"] = obj.get("exactOnSingleWordQuery") obj["alternativesAsExact"] = obj.get("alternativesAsExact") obj["advancedSyntaxFeatures"] = obj.get("advancedSyntaxFeatures") diff --git a/algoliasearch/search/models/browse_params_object.py b/algoliasearch/search/models/browse_params_object.py index fd36dd39e..f824e5235 100644 --- a/algoliasearch/search/models/browse_params_object.py +++ b/algoliasearch/search/models/browse_params_object.py @@ -28,9 +28,11 @@ ) from algoliasearch.search.models.facet_filters import FacetFilters from algoliasearch.search.models.ignore_plurals import IgnorePlurals +from algoliasearch.search.models.inside_bounding_box import InsideBoundingBox from algoliasearch.search.models.mode import Mode from algoliasearch.search.models.numeric_filters import NumericFilters from algoliasearch.search.models.optional_filters import OptionalFilters +from algoliasearch.search.models.optional_words import OptionalWords from algoliasearch.search.models.query_type import QueryType from algoliasearch.search.models.re_ranking_apply_filter import ReRankingApplyFilter from algoliasearch.search.models.remove_stop_words import RemoveStopWords @@ -113,7 +115,6 @@ "replace_synonyms_in_highlight": "replaceSynonymsInHighlight", "min_proximity": "minProximity", "response_fields": "responseFields", - "max_facet_hits": "maxFacetHits", "max_values_per_facet": "maxValuesPerFacet", "sort_facet_values_by": "sortFacetValuesBy", "attribute_criteria_computed_by_min_proximity": "attributeCriteriaComputedByMinProximity", @@ -165,8 +166,7 @@ class BrowseParamsObject(BaseModel): around_precision: Optional[AroundPrecision] = None minimum_around_radius: Optional[int] = None """ Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. """ - inside_bounding_box: Optional[List[List[float]]] = None - """ 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). """ + inside_bounding_box: Optional[InsideBoundingBox] = None inside_polygon: Optional[List[List[float]]] = None """ 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`. """ natural_languages: Optional[List[SupportedLanguage]] = None @@ -240,8 +240,7 @@ class BrowseParamsObject(BaseModel): semantic_search: Optional[SemanticSearch] = None advanced_syntax: Optional[bool] = None """ Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. """ - optional_words: Optional[List[str]] = None - """ 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). """ + optional_words: Optional[OptionalWords] = None disable_exact_on_attributes: Optional[List[str]] = None """ 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. """ exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = None @@ -256,8 +255,6 @@ class BrowseParamsObject(BaseModel): """ 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. """ response_fields: Optional[List[str]] = None """ 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. """ - max_facet_hits: Optional[int] = None - """ 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). """ max_values_per_facet: Optional[int] = None """ Maximum number of facet values to return for each facet. """ sort_facet_values_by: Optional[str] = None @@ -334,6 +331,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("aroundPrecision") is not None else None ) + obj["insideBoundingBox"] = ( + InsideBoundingBox.from_dict(obj["insideBoundingBox"]) + if obj.get("insideBoundingBox") is not None + else None + ) obj["naturalLanguages"] = obj.get("naturalLanguages") obj["typoTolerance"] = ( TypoTolerance.from_dict(obj["typoTolerance"]) @@ -359,6 +361,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("semanticSearch") is not None else None ) + obj["optionalWords"] = ( + OptionalWords.from_dict(obj["optionalWords"]) + if obj.get("optionalWords") is not None + else None + ) obj["exactOnSingleWordQuery"] = obj.get("exactOnSingleWordQuery") obj["alternativesAsExact"] = obj.get("alternativesAsExact") obj["advancedSyntaxFeatures"] = obj.get("advancedSyntaxFeatures") diff --git a/algoliasearch/search/models/consequence_params.py b/algoliasearch/search/models/consequence_params.py index 69560ece3..e3d30241b 100644 --- a/algoliasearch/search/models/consequence_params.py +++ b/algoliasearch/search/models/consequence_params.py @@ -30,9 +30,11 @@ ) from algoliasearch.search.models.facet_filters import FacetFilters from algoliasearch.search.models.ignore_plurals import IgnorePlurals +from algoliasearch.search.models.inside_bounding_box import InsideBoundingBox from algoliasearch.search.models.mode import Mode from algoliasearch.search.models.numeric_filters import NumericFilters from algoliasearch.search.models.optional_filters import OptionalFilters +from algoliasearch.search.models.optional_words import OptionalWords from algoliasearch.search.models.query_type import QueryType from algoliasearch.search.models.re_ranking_apply_filter import ReRankingApplyFilter from algoliasearch.search.models.remove_stop_words import RemoveStopWords @@ -114,7 +116,6 @@ "replace_synonyms_in_highlight": "replaceSynonymsInHighlight", "min_proximity": "minProximity", "response_fields": "responseFields", - "max_facet_hits": "maxFacetHits", "max_values_per_facet": "maxValuesPerFacet", "sort_facet_values_by": "sortFacetValuesBy", "attribute_criteria_computed_by_min_proximity": "attributeCriteriaComputedByMinProximity", @@ -166,8 +167,7 @@ class ConsequenceParams(BaseModel): around_precision: Optional[AroundPrecision] = None minimum_around_radius: Optional[int] = None """ Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. """ - inside_bounding_box: Optional[List[List[float]]] = None - """ 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). """ + inside_bounding_box: Optional[InsideBoundingBox] = None inside_polygon: Optional[List[List[float]]] = None """ 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`. """ natural_languages: Optional[List[SupportedLanguage]] = None @@ -241,8 +241,7 @@ class ConsequenceParams(BaseModel): semantic_search: Optional[SemanticSearch] = None advanced_syntax: Optional[bool] = None """ Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. """ - optional_words: Optional[List[str]] = None - """ 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). """ + optional_words: Optional[OptionalWords] = None disable_exact_on_attributes: Optional[List[str]] = None """ 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. """ exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = None @@ -257,8 +256,6 @@ class ConsequenceParams(BaseModel): """ 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. """ response_fields: Optional[List[str]] = None """ 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. """ - max_facet_hits: Optional[int] = None - """ 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). """ max_values_per_facet: Optional[int] = None """ Maximum number of facet values to return for each facet. """ sort_facet_values_by: Optional[str] = None @@ -336,6 +333,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("aroundPrecision") is not None else None ) + obj["insideBoundingBox"] = ( + InsideBoundingBox.from_dict(obj["insideBoundingBox"]) + if obj.get("insideBoundingBox") is not None + else None + ) obj["naturalLanguages"] = obj.get("naturalLanguages") obj["typoTolerance"] = ( TypoTolerance.from_dict(obj["typoTolerance"]) @@ -361,6 +363,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("semanticSearch") is not None else None ) + obj["optionalWords"] = ( + OptionalWords.from_dict(obj["optionalWords"]) + if obj.get("optionalWords") is not None + else None + ) obj["exactOnSingleWordQuery"] = obj.get("exactOnSingleWordQuery") obj["alternativesAsExact"] = obj.get("alternativesAsExact") obj["advancedSyntaxFeatures"] = obj.get("advancedSyntaxFeatures") diff --git a/algoliasearch/search/models/delete_by_params.py b/algoliasearch/search/models/delete_by_params.py index fa4e0589b..3433f01d5 100644 --- a/algoliasearch/search/models/delete_by_params.py +++ b/algoliasearch/search/models/delete_by_params.py @@ -20,6 +20,7 @@ from algoliasearch.search.models.around_radius import AroundRadius from algoliasearch.search.models.facet_filters import FacetFilters +from algoliasearch.search.models.inside_bounding_box import InsideBoundingBox from algoliasearch.search.models.numeric_filters import NumericFilters from algoliasearch.search.models.tag_filters import TagFilters @@ -52,8 +53,7 @@ class DeleteByParams(BaseModel): around_lat_lng: Optional[str] = None """ Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude. Only records included within a circle around this central location are included in the results. The radius of the circle is determined by the `aroundRadius` and `minimumAroundRadius` settings. This parameter is ignored if you also specify `insidePolygon` or `insideBoundingBox`. """ around_radius: Optional[AroundRadius] = None - inside_bounding_box: Optional[List[List[float]]] = None - """ 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). """ + inside_bounding_box: Optional[InsideBoundingBox] = None inside_polygon: Optional[List[List[float]]] = None """ 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`. """ @@ -110,5 +110,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("aroundRadius") is not None else None ) + obj["insideBoundingBox"] = ( + InsideBoundingBox.from_dict(obj["insideBoundingBox"]) + if obj.get("insideBoundingBox") is not None + else None + ) return cls.model_validate(obj) diff --git a/algoliasearch/search/models/index_settings.py b/algoliasearch/search/models/index_settings.py index de2eb156d..937aaa1e0 100644 --- a/algoliasearch/search/models/index_settings.py +++ b/algoliasearch/search/models/index_settings.py @@ -26,6 +26,7 @@ ) from algoliasearch.search.models.ignore_plurals import IgnorePlurals from algoliasearch.search.models.mode import Mode +from algoliasearch.search.models.optional_words import OptionalWords from algoliasearch.search.models.query_type import QueryType from algoliasearch.search.models.re_ranking_apply_filter import ReRankingApplyFilter from algoliasearch.search.models.remove_stop_words import RemoveStopWords @@ -55,6 +56,7 @@ "user_data": "userData", "custom_normalization": "customNormalization", "attribute_for_distinct": "attributeForDistinct", + "max_facet_hits": "maxFacetHits", "attributes_to_retrieve": "attributesToRetrieve", "ranking": "ranking", "custom_ranking": "customRanking", @@ -92,7 +94,6 @@ "replace_synonyms_in_highlight": "replaceSynonymsInHighlight", "min_proximity": "minProximity", "response_fields": "responseFields", - "max_facet_hits": "maxFacetHits", "max_values_per_facet": "maxValuesPerFacet", "sort_facet_values_by": "sortFacetValuesBy", "attribute_criteria_computed_by_min_proximity": "attributeCriteriaComputedByMinProximity", @@ -145,6 +146,8 @@ class IndexSettings(BaseModel): """ Characters and their normalized replacements. This overrides Algolia's default [normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/). """ attribute_for_distinct: Optional[str] = None """ Attribute that should be used to establish groups of results. Attribute names are case-sensitive. All records with the same value for this attribute are considered a group. You can combine `attributeForDistinct` with the `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. """ + max_facet_hits: Optional[int] = None + """ 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). """ attributes_to_retrieve: Optional[List[str]] = None """ 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 `customRanking` and `unretrievableAttributes` settings. - To retrieve all attributes except a specific one, prefix the attribute with a dash and combine it with the `*`: `[\"*\", \"-ATTRIBUTE\"]`. - The `objectID` attribute is always included. """ ranking: Optional[List[str]] = None @@ -194,8 +197,7 @@ class IndexSettings(BaseModel): semantic_search: Optional[SemanticSearch] = None advanced_syntax: Optional[bool] = None """ Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. """ - optional_words: Optional[List[str]] = None - """ 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). """ + optional_words: Optional[OptionalWords] = None disable_exact_on_attributes: Optional[List[str]] = None """ 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. """ exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = None @@ -210,8 +212,6 @@ class IndexSettings(BaseModel): """ 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. """ response_fields: Optional[List[str]] = None """ 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. """ - max_facet_hits: Optional[int] = None - """ 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). """ max_values_per_facet: Optional[int] = None """ Maximum number of facet values to return for each facet. """ sort_facet_values_by: Optional[str] = None @@ -281,6 +281,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("semanticSearch") is not None else None ) + obj["optionalWords"] = ( + OptionalWords.from_dict(obj["optionalWords"]) + if obj.get("optionalWords") is not None + else None + ) obj["exactOnSingleWordQuery"] = obj.get("exactOnSingleWordQuery") obj["alternativesAsExact"] = obj.get("alternativesAsExact") obj["advancedSyntaxFeatures"] = obj.get("advancedSyntaxFeatures") diff --git a/algoliasearch/search/models/inside_bounding_box.py b/algoliasearch/search/models/inside_bounding_box.py new file mode 100644 index 000000000..5c2edc010 --- /dev/null +++ b/algoliasearch/search/models/inside_bounding_box.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" +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. +""" + +from __future__ import annotations + +from json import dumps, loads +from sys import version_info +from typing import Any, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, Field, ValidationError, model_serializer + +if version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + + +class InsideBoundingBox(BaseModel): + """ + InsideBoundingBox + """ + + oneof_schema_1_validator: Optional[str] = Field(default=None) + + oneof_schema_2_validator: Optional[List[List[float]]] = Field(default=None) + """ 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). """ + actual_instance: Union[List[List[float]], str, None] = None + one_of_schemas: Set[str] = {"List[List[float]]", "str"} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError( + "If a position argument is used, only 1 is allowed to set `actual_instance`" + ) + if kwargs: + raise ValueError( + "If a position argument is used, keyword arguments cannot be used." + ) + super().__init__(actual_instance=args[0]) # pyright: ignore + else: + super().__init__(**kwargs) + + @model_serializer + def unwrap_actual_instance(self) -> Union[List[List[float]], str, Self, None]: + """ + Unwraps the `actual_instance` when calling the `to_json` method. + """ + return self.actual_instance if hasattr(self, "actual_instance") else self + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + """Create an instance of InsideBoundingBox from a JSON string""" + return cls.from_json(dumps(obj)) + + @classmethod + def from_json(cls, json_str: Optional[str]) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + if json_str is None: + return instance + + error_messages = [] + + try: + instance.oneof_schema_1_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_1_validator + + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + try: + instance.oneof_schema_2_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_2_validator + + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + raise ValueError( + "No match found when deserializing the JSON string into InsideBoundingBox with oneOf schemas: List[List[float]], str. Details: " + + ", ".join(error_messages) + ) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable( + self.actual_instance.to_json # pyright: ignore + ): + return self.actual_instance.to_json() # pyright: ignore + else: + return dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], List[List[float]], str]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable( + self.actual_instance.to_dict # pyright: ignore + ): + return self.actual_instance.to_dict() # pyright: ignore + else: + return self.actual_instance # pyright: ignore diff --git a/algoliasearch/search/models/optional_words.py b/algoliasearch/search/models/optional_words.py new file mode 100644 index 000000000..e19f73dd9 --- /dev/null +++ b/algoliasearch/search/models/optional_words.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" +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. +""" + +from __future__ import annotations + +from json import dumps, loads +from sys import version_info +from typing import Any, Dict, List, Optional, Set, Union + +from pydantic import BaseModel, Field, ValidationError, model_serializer + +if version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + + +class OptionalWords(BaseModel): + """ + OptionalWords + """ + + oneof_schema_1_validator: Optional[str] = Field(default=None) + + oneof_schema_2_validator: Optional[List[str]] = Field(default=None) + """ 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). """ + actual_instance: Union[List[str], str, None] = None + one_of_schemas: Set[str] = {"List[str]", "str"} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError( + "If a position argument is used, only 1 is allowed to set `actual_instance`" + ) + if kwargs: + raise ValueError( + "If a position argument is used, keyword arguments cannot be used." + ) + super().__init__(actual_instance=args[0]) # pyright: ignore + else: + super().__init__(**kwargs) + + @model_serializer + def unwrap_actual_instance(self) -> Union[List[str], str, Self, None]: + """ + Unwraps the `actual_instance` when calling the `to_json` method. + """ + return self.actual_instance if hasattr(self, "actual_instance") else self + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + """Create an instance of OptionalWords from a JSON string""" + return cls.from_json(dumps(obj)) + + @classmethod + def from_json(cls, json_str: Optional[str]) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + if json_str is None: + return instance + + error_messages = [] + + try: + instance.oneof_schema_1_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_1_validator + + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + try: + instance.oneof_schema_2_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_2_validator + + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + raise ValueError( + "No match found when deserializing the JSON string into OptionalWords with oneOf schemas: List[str], str. Details: " + + ", ".join(error_messages) + ) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable( + self.actual_instance.to_json # pyright: ignore + ): + return self.actual_instance.to_json() # pyright: ignore + else: + return dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], List[str], str]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable( + self.actual_instance.to_dict # pyright: ignore + ): + return self.actual_instance.to_dict() # pyright: ignore + else: + return self.actual_instance # pyright: ignore diff --git a/algoliasearch/search/models/search_for_facets.py b/algoliasearch/search/models/search_for_facets.py index 709521b1c..13c88abeb 100644 --- a/algoliasearch/search/models/search_for_facets.py +++ b/algoliasearch/search/models/search_for_facets.py @@ -28,9 +28,11 @@ ) from algoliasearch.search.models.facet_filters import FacetFilters from algoliasearch.search.models.ignore_plurals import IgnorePlurals +from algoliasearch.search.models.inside_bounding_box import InsideBoundingBox from algoliasearch.search.models.mode import Mode from algoliasearch.search.models.numeric_filters import NumericFilters from algoliasearch.search.models.optional_filters import OptionalFilters +from algoliasearch.search.models.optional_words import OptionalWords from algoliasearch.search.models.query_type import QueryType from algoliasearch.search.models.re_ranking_apply_filter import ReRankingApplyFilter from algoliasearch.search.models.remove_stop_words import RemoveStopWords @@ -115,7 +117,6 @@ "replace_synonyms_in_highlight": "replaceSynonymsInHighlight", "min_proximity": "minProximity", "response_fields": "responseFields", - "max_facet_hits": "maxFacetHits", "max_values_per_facet": "maxValuesPerFacet", "sort_facet_values_by": "sortFacetValuesBy", "attribute_criteria_computed_by_min_proximity": "attributeCriteriaComputedByMinProximity", @@ -125,6 +126,7 @@ "facet": "facet", "index_name": "indexName", "facet_query": "facetQuery", + "max_facet_hits": "maxFacetHits", "type": "type", } @@ -172,8 +174,7 @@ class SearchForFacets(BaseModel): around_precision: Optional[AroundPrecision] = None minimum_around_radius: Optional[int] = None """ Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. """ - inside_bounding_box: Optional[List[List[float]]] = None - """ 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). """ + inside_bounding_box: Optional[InsideBoundingBox] = None inside_polygon: Optional[List[List[float]]] = None """ 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`. """ natural_languages: Optional[List[SupportedLanguage]] = None @@ -247,8 +248,7 @@ class SearchForFacets(BaseModel): semantic_search: Optional[SemanticSearch] = None advanced_syntax: Optional[bool] = None """ Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. """ - optional_words: Optional[List[str]] = None - """ 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). """ + optional_words: Optional[OptionalWords] = None disable_exact_on_attributes: Optional[List[str]] = None """ 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. """ exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = None @@ -263,8 +263,6 @@ class SearchForFacets(BaseModel): """ 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. """ response_fields: Optional[List[str]] = None """ 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. """ - max_facet_hits: Optional[int] = None - """ 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). """ max_values_per_facet: Optional[int] = None """ Maximum number of facet values to return for each facet. """ sort_facet_values_by: Optional[str] = None @@ -281,6 +279,8 @@ class SearchForFacets(BaseModel): """ Index name (case-sensitive). """ facet_query: Optional[str] = None """ Text to search inside the facet's values. """ + max_facet_hits: Optional[int] = None + """ 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). """ type: SearchTypeFacet model_config = ConfigDict( @@ -346,6 +346,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("aroundPrecision") is not None else None ) + obj["insideBoundingBox"] = ( + InsideBoundingBox.from_dict(obj["insideBoundingBox"]) + if obj.get("insideBoundingBox") is not None + else None + ) obj["naturalLanguages"] = obj.get("naturalLanguages") obj["typoTolerance"] = ( TypoTolerance.from_dict(obj["typoTolerance"]) @@ -371,6 +376,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("semanticSearch") is not None else None ) + obj["optionalWords"] = ( + OptionalWords.from_dict(obj["optionalWords"]) + if obj.get("optionalWords") is not None + else None + ) obj["exactOnSingleWordQuery"] = obj.get("exactOnSingleWordQuery") obj["alternativesAsExact"] = obj.get("alternativesAsExact") obj["advancedSyntaxFeatures"] = obj.get("advancedSyntaxFeatures") diff --git a/algoliasearch/search/models/search_for_hits.py b/algoliasearch/search/models/search_for_hits.py index 03efe9246..aa6f16b4a 100644 --- a/algoliasearch/search/models/search_for_hits.py +++ b/algoliasearch/search/models/search_for_hits.py @@ -28,9 +28,11 @@ ) from algoliasearch.search.models.facet_filters import FacetFilters from algoliasearch.search.models.ignore_plurals import IgnorePlurals +from algoliasearch.search.models.inside_bounding_box import InsideBoundingBox from algoliasearch.search.models.mode import Mode from algoliasearch.search.models.numeric_filters import NumericFilters from algoliasearch.search.models.optional_filters import OptionalFilters +from algoliasearch.search.models.optional_words import OptionalWords from algoliasearch.search.models.query_type import QueryType from algoliasearch.search.models.re_ranking_apply_filter import ReRankingApplyFilter from algoliasearch.search.models.remove_stop_words import RemoveStopWords @@ -115,7 +117,6 @@ "replace_synonyms_in_highlight": "replaceSynonymsInHighlight", "min_proximity": "minProximity", "response_fields": "responseFields", - "max_facet_hits": "maxFacetHits", "max_values_per_facet": "maxValuesPerFacet", "sort_facet_values_by": "sortFacetValuesBy", "attribute_criteria_computed_by_min_proximity": "attributeCriteriaComputedByMinProximity", @@ -170,8 +171,7 @@ class SearchForHits(BaseModel): around_precision: Optional[AroundPrecision] = None minimum_around_radius: Optional[int] = None """ Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. """ - inside_bounding_box: Optional[List[List[float]]] = None - """ 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). """ + inside_bounding_box: Optional[InsideBoundingBox] = None inside_polygon: Optional[List[List[float]]] = None """ 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`. """ natural_languages: Optional[List[SupportedLanguage]] = None @@ -245,8 +245,7 @@ class SearchForHits(BaseModel): semantic_search: Optional[SemanticSearch] = None advanced_syntax: Optional[bool] = None """ Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. """ - optional_words: Optional[List[str]] = None - """ 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). """ + optional_words: Optional[OptionalWords] = None disable_exact_on_attributes: Optional[List[str]] = None """ 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. """ exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = None @@ -261,8 +260,6 @@ class SearchForHits(BaseModel): """ 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. """ response_fields: Optional[List[str]] = None """ 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. """ - max_facet_hits: Optional[int] = None - """ 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). """ max_values_per_facet: Optional[int] = None """ Maximum number of facet values to return for each facet. """ sort_facet_values_by: Optional[str] = None @@ -340,6 +337,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("aroundPrecision") is not None else None ) + obj["insideBoundingBox"] = ( + InsideBoundingBox.from_dict(obj["insideBoundingBox"]) + if obj.get("insideBoundingBox") is not None + else None + ) obj["naturalLanguages"] = obj.get("naturalLanguages") obj["typoTolerance"] = ( TypoTolerance.from_dict(obj["typoTolerance"]) @@ -365,6 +367,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("semanticSearch") is not None else None ) + obj["optionalWords"] = ( + OptionalWords.from_dict(obj["optionalWords"]) + if obj.get("optionalWords") is not None + else None + ) obj["exactOnSingleWordQuery"] = obj.get("exactOnSingleWordQuery") obj["alternativesAsExact"] = obj.get("alternativesAsExact") obj["advancedSyntaxFeatures"] = obj.get("advancedSyntaxFeatures") diff --git a/algoliasearch/search/models/search_params_object.py b/algoliasearch/search/models/search_params_object.py index 9885d151b..4078c2085 100644 --- a/algoliasearch/search/models/search_params_object.py +++ b/algoliasearch/search/models/search_params_object.py @@ -28,9 +28,11 @@ ) from algoliasearch.search.models.facet_filters import FacetFilters from algoliasearch.search.models.ignore_plurals import IgnorePlurals +from algoliasearch.search.models.inside_bounding_box import InsideBoundingBox from algoliasearch.search.models.mode import Mode from algoliasearch.search.models.numeric_filters import NumericFilters from algoliasearch.search.models.optional_filters import OptionalFilters +from algoliasearch.search.models.optional_words import OptionalWords from algoliasearch.search.models.query_type import QueryType from algoliasearch.search.models.re_ranking_apply_filter import ReRankingApplyFilter from algoliasearch.search.models.remove_stop_words import RemoveStopWords @@ -113,7 +115,6 @@ "replace_synonyms_in_highlight": "replaceSynonymsInHighlight", "min_proximity": "minProximity", "response_fields": "responseFields", - "max_facet_hits": "maxFacetHits", "max_values_per_facet": "maxValuesPerFacet", "sort_facet_values_by": "sortFacetValuesBy", "attribute_criteria_computed_by_min_proximity": "attributeCriteriaComputedByMinProximity", @@ -164,8 +165,7 @@ class SearchParamsObject(BaseModel): around_precision: Optional[AroundPrecision] = None minimum_around_radius: Optional[int] = None """ Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set. """ - inside_bounding_box: Optional[List[List[float]]] = None - """ 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). """ + inside_bounding_box: Optional[InsideBoundingBox] = None inside_polygon: Optional[List[List[float]]] = None """ 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`. """ natural_languages: Optional[List[SupportedLanguage]] = None @@ -239,8 +239,7 @@ class SearchParamsObject(BaseModel): semantic_search: Optional[SemanticSearch] = None advanced_syntax: Optional[bool] = None """ Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. """ - optional_words: Optional[List[str]] = None - """ 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). """ + optional_words: Optional[OptionalWords] = None disable_exact_on_attributes: Optional[List[str]] = None """ 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. """ exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = None @@ -255,8 +254,6 @@ class SearchParamsObject(BaseModel): """ 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. """ response_fields: Optional[List[str]] = None """ 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. """ - max_facet_hits: Optional[int] = None - """ 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). """ max_values_per_facet: Optional[int] = None """ Maximum number of facet values to return for each facet. """ sort_facet_values_by: Optional[str] = None @@ -331,6 +328,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("aroundPrecision") is not None else None ) + obj["insideBoundingBox"] = ( + InsideBoundingBox.from_dict(obj["insideBoundingBox"]) + if obj.get("insideBoundingBox") is not None + else None + ) obj["naturalLanguages"] = obj.get("naturalLanguages") obj["typoTolerance"] = ( TypoTolerance.from_dict(obj["typoTolerance"]) @@ -356,6 +358,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("semanticSearch") is not None else None ) + obj["optionalWords"] = ( + OptionalWords.from_dict(obj["optionalWords"]) + if obj.get("optionalWords") is not None + else None + ) obj["exactOnSingleWordQuery"] = obj.get("exactOnSingleWordQuery") obj["alternativesAsExact"] = obj.get("alternativesAsExact") obj["advancedSyntaxFeatures"] = obj.get("advancedSyntaxFeatures") diff --git a/algoliasearch/search/models/settings_response.py b/algoliasearch/search/models/settings_response.py index 033bf3c2e..82c6721cf 100644 --- a/algoliasearch/search/models/settings_response.py +++ b/algoliasearch/search/models/settings_response.py @@ -26,6 +26,7 @@ ) from algoliasearch.search.models.ignore_plurals import IgnorePlurals from algoliasearch.search.models.mode import Mode +from algoliasearch.search.models.optional_words import OptionalWords from algoliasearch.search.models.query_type import QueryType from algoliasearch.search.models.re_ranking_apply_filter import ReRankingApplyFilter from algoliasearch.search.models.remove_stop_words import RemoveStopWords @@ -55,6 +56,7 @@ "user_data": "userData", "custom_normalization": "customNormalization", "attribute_for_distinct": "attributeForDistinct", + "max_facet_hits": "maxFacetHits", "attributes_to_retrieve": "attributesToRetrieve", "ranking": "ranking", "custom_ranking": "customRanking", @@ -92,7 +94,6 @@ "replace_synonyms_in_highlight": "replaceSynonymsInHighlight", "min_proximity": "minProximity", "response_fields": "responseFields", - "max_facet_hits": "maxFacetHits", "max_values_per_facet": "maxValuesPerFacet", "sort_facet_values_by": "sortFacetValuesBy", "attribute_criteria_computed_by_min_proximity": "attributeCriteriaComputedByMinProximity", @@ -146,6 +147,8 @@ class SettingsResponse(BaseModel): """ Characters and their normalized replacements. This overrides Algolia's default [normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/). """ attribute_for_distinct: Optional[str] = None """ Attribute that should be used to establish groups of results. Attribute names are case-sensitive. All records with the same value for this attribute are considered a group. You can combine `attributeForDistinct` with the `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. """ + max_facet_hits: Optional[int] = None + """ 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). """ attributes_to_retrieve: Optional[List[str]] = None """ 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 `customRanking` and `unretrievableAttributes` settings. - To retrieve all attributes except a specific one, prefix the attribute with a dash and combine it with the `*`: `[\"*\", \"-ATTRIBUTE\"]`. - The `objectID` attribute is always included. """ ranking: Optional[List[str]] = None @@ -195,8 +198,7 @@ class SettingsResponse(BaseModel): semantic_search: Optional[SemanticSearch] = None advanced_syntax: Optional[bool] = None """ Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported. """ - optional_words: Optional[List[str]] = None - """ 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). """ + optional_words: Optional[OptionalWords] = None disable_exact_on_attributes: Optional[List[str]] = None """ 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. """ exact_on_single_word_query: Optional[ExactOnSingleWordQuery] = None @@ -211,8 +213,6 @@ class SettingsResponse(BaseModel): """ 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. """ response_fields: Optional[List[str]] = None """ 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. """ - max_facet_hits: Optional[int] = None - """ 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). """ max_values_per_facet: Optional[int] = None """ Maximum number of facet values to return for each facet. """ sort_facet_values_by: Optional[str] = None @@ -284,6 +284,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("semanticSearch") is not None else None ) + obj["optionalWords"] = ( + OptionalWords.from_dict(obj["optionalWords"]) + if obj.get("optionalWords") is not None + else None + ) obj["exactOnSingleWordQuery"] = obj.get("exactOnSingleWordQuery") obj["alternativesAsExact"] = obj.get("alternativesAsExact") obj["advancedSyntaxFeatures"] = obj.get("advancedSyntaxFeatures")