algolia 3.25.0 → 3.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/issue.yml +1 -1
  3. data/.github/workflows/release.yml +1 -1
  4. data/CHANGELOG.md +10 -0
  5. data/Gemfile.lock +1 -1
  6. data/lib/algolia/api/composition_client.rb +765 -0
  7. data/lib/algolia/api/ingestion_client.rb +15 -4
  8. data/lib/algolia/api/search_client.rb +4 -2
  9. data/lib/algolia/models/composition/action.rb +34 -0
  10. data/lib/algolia/models/composition/advanced_syntax_features.rb +34 -0
  11. data/lib/algolia/models/composition/alternatives_as_exact.rb +36 -0
  12. data/lib/algolia/models/composition/anchoring.rb +36 -0
  13. data/lib/algolia/models/composition/base_injection_query_parameters.rb +732 -0
  14. data/lib/algolia/models/composition/batch_composition_action.rb +109 -0
  15. data/lib/algolia/models/composition/batch_params.rb +213 -0
  16. data/lib/algolia/models/composition/boolean_string.rb +34 -0
  17. data/lib/algolia/models/composition/composition.rb +244 -0
  18. data/lib/algolia/models/composition/composition_behavior.rb +210 -0
  19. data/lib/algolia/models/composition/composition_rule.rb +280 -0
  20. data/lib/algolia/models/composition/composition_rule_consequence.rb +211 -0
  21. data/lib/algolia/models/composition/composition_rules_batch_params.rb +211 -0
  22. data/lib/algolia/models/composition/composition_source.rb +210 -0
  23. data/lib/algolia/models/composition/composition_source_search.rb +220 -0
  24. data/lib/algolia/models/composition/condition.rb +238 -0
  25. data/lib/algolia/models/composition/delete_composition_action.rb +212 -0
  26. data/lib/algolia/models/composition/delete_composition_rule_action.rb +212 -0
  27. data/lib/algolia/models/composition/distinct.rb +110 -0
  28. data/lib/algolia/models/composition/exact_on_single_word_query.rb +35 -0
  29. data/lib/algolia/models/composition/external.rb +226 -0
  30. data/lib/algolia/models/composition/external_ordering.rb +34 -0
  31. data/lib/algolia/models/composition/external_source.rb +211 -0
  32. data/lib/algolia/models/composition/get_task_response.rb +210 -0
  33. data/lib/algolia/models/composition/ignore_plurals.rb +111 -0
  34. data/lib/algolia/models/composition/injected_item.rb +253 -0
  35. data/lib/algolia/models/composition/injected_item_hits_metadata.rb +222 -0
  36. data/lib/algolia/models/composition/injected_item_metadata.rb +209 -0
  37. data/lib/algolia/models/composition/injected_item_source.rb +109 -0
  38. data/lib/algolia/models/composition/injection.rb +222 -0
  39. data/lib/algolia/models/composition/list_compositions_response.rb +261 -0
  40. data/lib/algolia/models/composition/main.rb +207 -0
  41. data/lib/algolia/models/composition/main_injection_query_parameters.rb +807 -0
  42. data/lib/algolia/models/composition/multiple_batch_request.rb +221 -0
  43. data/lib/algolia/models/composition/multiple_batch_response.rb +213 -0
  44. data/lib/algolia/models/composition/optional_words.rb +110 -0
  45. data/lib/algolia/models/composition/query_type.rb +35 -0
  46. data/lib/algolia/models/composition/remove_stop_words.rb +110 -0
  47. data/lib/algolia/models/composition/remove_words_if_no_results.rb +36 -0
  48. data/lib/algolia/models/composition/rules_batch_composition_action.rb +109 -0
  49. data/lib/algolia/models/composition/rules_multiple_batch_request.rb +221 -0
  50. data/lib/algolia/models/composition/rules_multiple_batch_response.rb +211 -0
  51. data/lib/algolia/models/composition/search.rb +217 -0
  52. data/lib/algolia/models/composition/search_composition_rules_params.rb +261 -0
  53. data/lib/algolia/models/composition/search_composition_rules_response.rb +249 -0
  54. data/lib/algolia/models/composition/search_source.rb +211 -0
  55. data/lib/algolia/models/composition/task_id_response.rb +211 -0
  56. data/lib/algolia/models/composition/task_status.rb +34 -0
  57. data/lib/algolia/models/composition/time_range.rb +219 -0
  58. data/lib/algolia/models/composition/typo_tolerance.rb +110 -0
  59. data/lib/algolia/models/composition/typo_tolerance_enum.rb +36 -0
  60. data/lib/algolia/version.rb +1 -1
  61. metadata +52 -1
@@ -0,0 +1,732 @@
1
+ # frozen_string_literal: true
2
+
3
+ # 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.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Composition
10
+ class BaseInjectionQueryParameters
11
+ # Whether to support phrase matching and excluding words from search queries Use the `advancedSyntaxFeatures` parameter to control which feature is supported.
12
+ attr_accessor :advanced_syntax
13
+
14
+ # Advanced search syntax features you want to support - `exactPhrase`. Phrases in quotes must match exactly. For example, `sparkly blue \"iPhone case\"` only returns records with the exact string \"iPhone case\" - `excludeWords`. Query words prefixed with a `-` must not occur in a record. For example, `search -engine` matches records that contain \"search\" but not \"engine\" This setting only has an effect if `advancedSyntax` is true.
15
+ attr_accessor :advanced_syntax_features
16
+
17
+ # Whether to allow typos on numbers in the search query Turn off this setting to reduce the number of irrelevant matches when searching in large sets of similar numbers.
18
+ attr_accessor :allow_typos_on_numeric_tokens
19
+
20
+ # Determine which plurals and synonyms should be considered an exact matches By default, Algolia treats singular and plural forms of a word, and single-word synonyms, as [exact](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/#exact) matches when searching. For example - \"swimsuit\" and \"swimsuits\" are treated the same - \"swimsuit\" and \"swimwear\" are treated the same (if they are [synonyms](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/#regular-synonyms)) - `ignorePlurals`. Plurals and similar declensions added by the `ignorePlurals` setting are considered exact matches - `singleWordSynonym`. Single-word synonyms, such as \"NY\" = \"NYC\", are considered exact matches - `multiWordsSynonym`. Multi-word synonyms, such as \"NY\" = \"New York\", are considered exact matches.
21
+ attr_accessor :alternatives_as_exact
22
+
23
+ # Whether this search will be included in Analytics.
24
+ attr_accessor :analytics
25
+
26
+ # Whether the best matching attribute should be determined by minimum proximity This setting only affects ranking if the Attribute ranking criterion comes before Proximity in the `ranking` setting. If true, the best matching attribute is selected based on the minimum proximity of multiple matches. Otherwise, the best matching attribute is determined by the order in the `searchableAttributes` setting.
27
+ attr_accessor :attribute_criteria_computed_by_min_proximity
28
+
29
+ # Attributes to highlight By default, all searchable attributes are highlighted. Use `*` to highlight all attributes or use an empty array `[]` to turn off highlighting. Attribute names are case-sensitive With highlighting, strings that match the search query are surrounded by HTML tags defined by `highlightPreTag` and `highlightPostTag`. You can use this to visually highlight matching parts of a search query in your UI For more information, see [Highlighting and snippeting](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/highlighting-snippeting/js/).
30
+ attr_accessor :attributes_to_highlight
31
+
32
+ # 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.
33
+ attr_accessor :attributes_to_retrieve
34
+
35
+ # Attributes for which to enable snippets. Attribute names are case-sensitive Snippets provide additional context to matched words. If you enable snippets, they include 10 words, including the matched word. The matched word will also be wrapped by HTML tags for highlighting. You can adjust the number of words with the following notation: `ATTRIBUTE:NUMBER`, where `NUMBER` is the number of words to be extracted.
36
+ attr_accessor :attributes_to_snippet
37
+
38
+ # Whether to include a `queryID` attribute in the response The query ID is a unique identifier for a search query and is required for tracking [click and conversion events](https://www.algolia.com/guides/sending-events/getting-started/).
39
+ attr_accessor :click_analytics
40
+
41
+ # Whether to split compound words in the query into their building blocks For more information, see [Word segmentation](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/#splitting-compound-words). Word segmentation is supported for these languages: German, Dutch, Finnish, Swedish, and Norwegian. Decompounding doesn't work for words with [non-spacing mark Unicode characters](https://www.charactercodes.net/category/non-spacing_mark). For example, `Gartenstühle` won't be decompounded if the `ü` consists of `u` (U+0075) and `◌̈` (U+0308).
42
+ attr_accessor :decompound_query
43
+
44
+ # 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.
45
+ attr_accessor :disable_exact_on_attributes
46
+
47
+ # Attributes for which you want to turn off [typo tolerance](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/). Attribute names are case-sensitive Returning only exact matches can help when - [Searching in hyphenated attributes](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/how-to/how-to-search-in-hyphenated-attributes/). - Reducing the number of matches when you have too many. This can happen with attributes that are long blocks of text, such as product descriptions Consider alternatives such as `disableTypoToleranceOnWords` or adding synonyms if your attributes have intentional unusual spellings that might look like typos.
48
+ attr_accessor :disable_typo_tolerance_on_attributes
49
+
50
+ attr_accessor :distinct
51
+
52
+ # Whether to enable A/B testing for this search.
53
+ attr_accessor :enable_ab_test
54
+
55
+ # Whether to enable Personalization.
56
+ attr_accessor :enable_personalization
57
+
58
+ # Whether this search will use [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/) This setting only has an effect if you activated Dynamic Re-Ranking for this index in the Algolia dashboard.
59
+ attr_accessor :enable_re_ranking
60
+
61
+ # Whether to enable rules.
62
+ attr_accessor :enable_rules
63
+
64
+ attr_accessor :exact_on_single_word_query
65
+
66
+ attr_accessor :facet_filters
67
+
68
+ # Filter expression to only include items that match the filter criteria in the response. You can use these filter expressions: - **Numeric filters.** `<facet> <op> <number>`, where `<op>` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `<facet>:<lower> TO <upper>` where `<lower>` and `<upper>` are the lower and upper limits of the range (inclusive). - **Facet filters.** `<facet>:<value>` where `<facet>` is a facet attribute (case-sensitive) and `<value>` a facet value. - **Tag filters.** `_tags:<value>` or just `<value>` (case-sensitive). - **Boolean filters.** `<facet>: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/).
69
+ attr_accessor :filters
70
+
71
+ # Whether the search response should include detailed ranking information.
72
+ attr_accessor :get_ranking_info
73
+
74
+ # HTML tag to insert after the highlighted parts in all highlighted results and snippets.
75
+ attr_accessor :highlight_post_tag
76
+
77
+ # HTML tag to insert before the highlighted parts in all highlighted results and snippets.
78
+ attr_accessor :highlight_pre_tag
79
+
80
+ attr_accessor :ignore_plurals
81
+
82
+ # 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).
83
+ attr_accessor :max_facet_hits
84
+
85
+ # 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.
86
+ attr_accessor :min_proximity
87
+
88
+ # Minimum number of characters a word in the search query must contain to accept matches with [one typo](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/in-depth/configuring-typo-tolerance/#configuring-word-length-for-typos).
89
+ attr_accessor :min_word_sizefor1_typo
90
+
91
+ # Minimum number of characters a word in the search query must contain to accept matches with [two typos](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/typo-tolerance/in-depth/configuring-typo-tolerance/#configuring-word-length-for-typos).
92
+ attr_accessor :min_word_sizefor2_typos
93
+
94
+ # ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to keyword searches) - Sets `removeStopWords` and `ignorePlurals` to the list of provided languages. - Sets `removeWordsIfNoResults` to `allOptional`. - Adds a `natural_language` attribute to `ruleContexts` and `analyticsTags`.
95
+ attr_accessor :natural_languages
96
+
97
+ attr_accessor :numeric_filters
98
+
99
+ attr_accessor :optional_filters
100
+
101
+ attr_accessor :optional_words
102
+
103
+ # Whether to include this search when calculating processing-time percentiles.
104
+ attr_accessor :percentile_computation
105
+
106
+ # Impact that Personalization should have on this search The higher this value is, the more Personalization determines the ranking compared to other factors. For more information, see [Understanding Personalization impact](https://www.algolia.com/doc/guides/personalization/personalizing-results/in-depth/configuring-personalization/#understanding-personalization-impact).
107
+ attr_accessor :personalization_impact
108
+
109
+ # Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection dictionaries This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals` settings. This setting also sets a dictionary for word detection in the logogram-based [CJK](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#normalization-for-logogram-based-languages-cjk) languages. To support this, you must place the CJK language **first** **You should always specify a query language.** If you don't specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/), or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to unexpected search results. For more information, see [Language-specific configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/).
110
+ attr_accessor :query_languages
111
+
112
+ attr_accessor :query_type
113
+
114
+ attr_accessor :remove_stop_words
115
+
116
+ attr_accessor :remove_words_if_no_results
117
+
118
+ # Whether to replace a highlighted word with the matched synonym By default, the original words are highlighted even if a synonym matches. For example, with `home` as a synonym for `house` and a search for `home`, records matching either \"home\" or \"house\" are included in the search results, and either \"home\" or \"house\" are highlighted With `replaceSynonymsInHighlight` set to `true`, a search for `home` still matches the same records, but all occurrences of \"house\" are replaced by \"home\" in the highlighted response.
119
+ attr_accessor :replace_synonyms_in_highlight
120
+
121
+ # 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 properties should be included An empty list may lead to an empty API response (except properties you can't exclude) You can't exclude these properties: `message`, `warning`, `cursor`, `abTestVariantID`, or any property added by setting `getRankingInfo` to true Your search depends on the `hits` field. If you omit this field, searches won't return any results. Your UI might also depend on other properties, for example, for pagination. Before restricting the response size, check the impact on your search experience.
122
+ attr_accessor :response_fields
123
+
124
+ # Whether to restrict highlighting and snippeting to items that at least partially matched the search query. By default, all items are highlighted and snippeted.
125
+ attr_accessor :restrict_highlight_and_snippet_arrays
126
+
127
+ # Restricts a search to a subset of your searchable attributes. Attribute names are case-sensitive.
128
+ attr_accessor :restrict_searchable_attributes
129
+
130
+ # Assigns a rule context to the search query [Rule contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context) are strings that you can use to trigger matching rules.
131
+ attr_accessor :rule_contexts
132
+
133
+ # String used as an ellipsis indicator when a snippet is truncated.
134
+ attr_accessor :snippet_ellipsis_text
135
+
136
+ # Whether to take into account an index's synonyms for this search.
137
+ attr_accessor :synonyms
138
+
139
+ attr_accessor :typo_tolerance
140
+
141
+ # Attribute mapping from ruby-style variable name to JSON key.
142
+ def self.attribute_map
143
+ {
144
+ :advanced_syntax => :advancedSyntax,
145
+ :advanced_syntax_features => :advancedSyntaxFeatures,
146
+ :allow_typos_on_numeric_tokens => :allowTyposOnNumericTokens,
147
+ :alternatives_as_exact => :alternativesAsExact,
148
+ :analytics => :analytics,
149
+ :attribute_criteria_computed_by_min_proximity => :attributeCriteriaComputedByMinProximity,
150
+ :attributes_to_highlight => :attributesToHighlight,
151
+ :attributes_to_retrieve => :attributesToRetrieve,
152
+ :attributes_to_snippet => :attributesToSnippet,
153
+ :click_analytics => :clickAnalytics,
154
+ :decompound_query => :decompoundQuery,
155
+ :disable_exact_on_attributes => :disableExactOnAttributes,
156
+ :disable_typo_tolerance_on_attributes => :disableTypoToleranceOnAttributes,
157
+ :distinct => :distinct,
158
+ :enable_ab_test => :enableABTest,
159
+ :enable_personalization => :enablePersonalization,
160
+ :enable_re_ranking => :enableReRanking,
161
+ :enable_rules => :enableRules,
162
+ :exact_on_single_word_query => :exactOnSingleWordQuery,
163
+ :facet_filters => :facetFilters,
164
+ :filters => :filters,
165
+ :get_ranking_info => :getRankingInfo,
166
+ :highlight_post_tag => :highlightPostTag,
167
+ :highlight_pre_tag => :highlightPreTag,
168
+ :ignore_plurals => :ignorePlurals,
169
+ :max_facet_hits => :maxFacetHits,
170
+ :min_proximity => :minProximity,
171
+ :min_word_sizefor1_typo => :minWordSizefor1Typo,
172
+ :min_word_sizefor2_typos => :minWordSizefor2Typos,
173
+ :natural_languages => :naturalLanguages,
174
+ :numeric_filters => :numericFilters,
175
+ :optional_filters => :optionalFilters,
176
+ :optional_words => :optionalWords,
177
+ :percentile_computation => :percentileComputation,
178
+ :personalization_impact => :personalizationImpact,
179
+ :query_languages => :queryLanguages,
180
+ :query_type => :queryType,
181
+ :remove_stop_words => :removeStopWords,
182
+ :remove_words_if_no_results => :removeWordsIfNoResults,
183
+ :replace_synonyms_in_highlight => :replaceSynonymsInHighlight,
184
+ :response_fields => :responseFields,
185
+ :restrict_highlight_and_snippet_arrays => :restrictHighlightAndSnippetArrays,
186
+ :restrict_searchable_attributes => :restrictSearchableAttributes,
187
+ :rule_contexts => :ruleContexts,
188
+ :snippet_ellipsis_text => :snippetEllipsisText,
189
+ :synonyms => :synonyms,
190
+ :typo_tolerance => :typoTolerance
191
+ }
192
+ end
193
+
194
+ # Attribute type mapping.
195
+ def self.types_mapping
196
+ {
197
+ :advanced_syntax => :"Boolean",
198
+ :advanced_syntax_features => :"Array<AdvancedSyntaxFeatures>",
199
+ :allow_typos_on_numeric_tokens => :"Boolean",
200
+ :alternatives_as_exact => :"Array<AlternativesAsExact>",
201
+ :analytics => :"Boolean",
202
+ :attribute_criteria_computed_by_min_proximity => :"Boolean",
203
+ :attributes_to_highlight => :"Array<String>",
204
+ :attributes_to_retrieve => :"Array<String>",
205
+ :attributes_to_snippet => :"Array<String>",
206
+ :click_analytics => :"Boolean",
207
+ :decompound_query => :"Boolean",
208
+ :disable_exact_on_attributes => :"Array<String>",
209
+ :disable_typo_tolerance_on_attributes => :"Array<String>",
210
+ :distinct => :"Distinct",
211
+ :enable_ab_test => :"Boolean",
212
+ :enable_personalization => :"Boolean",
213
+ :enable_re_ranking => :"Boolean",
214
+ :enable_rules => :"Boolean",
215
+ :exact_on_single_word_query => :"ExactOnSingleWordQuery",
216
+ :facet_filters => :"FacetFilters",
217
+ :filters => :"String",
218
+ :get_ranking_info => :"Boolean",
219
+ :highlight_post_tag => :"String",
220
+ :highlight_pre_tag => :"String",
221
+ :ignore_plurals => :"IgnorePlurals",
222
+ :max_facet_hits => :"Integer",
223
+ :min_proximity => :"Integer",
224
+ :min_word_sizefor1_typo => :"Integer",
225
+ :min_word_sizefor2_typos => :"Integer",
226
+ :natural_languages => :"Array<SupportedLanguage>",
227
+ :numeric_filters => :"NumericFilters",
228
+ :optional_filters => :"OptionalFilters",
229
+ :optional_words => :"OptionalWords",
230
+ :percentile_computation => :"Boolean",
231
+ :personalization_impact => :"Integer",
232
+ :query_languages => :"Array<SupportedLanguage>",
233
+ :query_type => :"QueryType",
234
+ :remove_stop_words => :"RemoveStopWords",
235
+ :remove_words_if_no_results => :"RemoveWordsIfNoResults",
236
+ :replace_synonyms_in_highlight => :"Boolean",
237
+ :response_fields => :"Array<String>",
238
+ :restrict_highlight_and_snippet_arrays => :"Boolean",
239
+ :restrict_searchable_attributes => :"Array<String>",
240
+ :rule_contexts => :"Array<String>",
241
+ :snippet_ellipsis_text => :"String",
242
+ :synonyms => :"Boolean",
243
+ :typo_tolerance => :"TypoTolerance"
244
+ }
245
+ end
246
+
247
+ # List of attributes with nullable: true
248
+ def self.openapi_nullable
249
+ Set.new(
250
+ [
251
+ :optional_words
252
+ ]
253
+ )
254
+ end
255
+
256
+ # Initializes the object
257
+ # @param [Hash] attributes Model attributes in the form of hash
258
+ def initialize(attributes = {})
259
+ if (!attributes.is_a?(Hash))
260
+ raise(
261
+ ArgumentError,
262
+ "The input argument (attributes) must be a hash in `Algolia::BaseInjectionQueryParameters` initialize method"
263
+ )
264
+ end
265
+
266
+ # check to see if the attribute exists and convert string to symbol for hash key
267
+ attributes = attributes.each_with_object({}) { |(k, v), h|
268
+ if (!self.class.attribute_map.key?(k.to_sym))
269
+ raise(
270
+ ArgumentError,
271
+ "`#{k}` is not a valid attribute in `Algolia::BaseInjectionQueryParameters`. Please check the name to make sure it's valid. List of attributes: " +
272
+ self.class.attribute_map.keys.inspect
273
+ )
274
+ end
275
+
276
+ h[k.to_sym] = v
277
+ }
278
+
279
+ if attributes.key?(:advanced_syntax)
280
+ self.advanced_syntax = attributes[:advanced_syntax]
281
+ end
282
+
283
+ if attributes.key?(:advanced_syntax_features)
284
+ if (value = attributes[:advanced_syntax_features]).is_a?(Array)
285
+ self.advanced_syntax_features = value
286
+ end
287
+ end
288
+
289
+ if attributes.key?(:allow_typos_on_numeric_tokens)
290
+ self.allow_typos_on_numeric_tokens = attributes[:allow_typos_on_numeric_tokens]
291
+ end
292
+
293
+ if attributes.key?(:alternatives_as_exact)
294
+ if (value = attributes[:alternatives_as_exact]).is_a?(Array)
295
+ self.alternatives_as_exact = value
296
+ end
297
+ end
298
+
299
+ if attributes.key?(:analytics)
300
+ self.analytics = attributes[:analytics]
301
+ end
302
+
303
+ if attributes.key?(:attribute_criteria_computed_by_min_proximity)
304
+ self.attribute_criteria_computed_by_min_proximity = attributes[:attribute_criteria_computed_by_min_proximity]
305
+ end
306
+
307
+ if attributes.key?(:attributes_to_highlight)
308
+ if (value = attributes[:attributes_to_highlight]).is_a?(Array)
309
+ self.attributes_to_highlight = value
310
+ end
311
+ end
312
+
313
+ if attributes.key?(:attributes_to_retrieve)
314
+ if (value = attributes[:attributes_to_retrieve]).is_a?(Array)
315
+ self.attributes_to_retrieve = value
316
+ end
317
+ end
318
+
319
+ if attributes.key?(:attributes_to_snippet)
320
+ if (value = attributes[:attributes_to_snippet]).is_a?(Array)
321
+ self.attributes_to_snippet = value
322
+ end
323
+ end
324
+
325
+ if attributes.key?(:click_analytics)
326
+ self.click_analytics = attributes[:click_analytics]
327
+ end
328
+
329
+ if attributes.key?(:decompound_query)
330
+ self.decompound_query = attributes[:decompound_query]
331
+ end
332
+
333
+ if attributes.key?(:disable_exact_on_attributes)
334
+ if (value = attributes[:disable_exact_on_attributes]).is_a?(Array)
335
+ self.disable_exact_on_attributes = value
336
+ end
337
+ end
338
+
339
+ if attributes.key?(:disable_typo_tolerance_on_attributes)
340
+ if (value = attributes[:disable_typo_tolerance_on_attributes]).is_a?(Array)
341
+ self.disable_typo_tolerance_on_attributes = value
342
+ end
343
+ end
344
+
345
+ if attributes.key?(:distinct)
346
+ self.distinct = attributes[:distinct]
347
+ end
348
+
349
+ if attributes.key?(:enable_ab_test)
350
+ self.enable_ab_test = attributes[:enable_ab_test]
351
+ end
352
+
353
+ if attributes.key?(:enable_personalization)
354
+ self.enable_personalization = attributes[:enable_personalization]
355
+ end
356
+
357
+ if attributes.key?(:enable_re_ranking)
358
+ self.enable_re_ranking = attributes[:enable_re_ranking]
359
+ end
360
+
361
+ if attributes.key?(:enable_rules)
362
+ self.enable_rules = attributes[:enable_rules]
363
+ end
364
+
365
+ if attributes.key?(:exact_on_single_word_query)
366
+ self.exact_on_single_word_query = attributes[:exact_on_single_word_query]
367
+ end
368
+
369
+ if attributes.key?(:facet_filters)
370
+ self.facet_filters = attributes[:facet_filters]
371
+ end
372
+
373
+ if attributes.key?(:filters)
374
+ self.filters = attributes[:filters]
375
+ end
376
+
377
+ if attributes.key?(:get_ranking_info)
378
+ self.get_ranking_info = attributes[:get_ranking_info]
379
+ end
380
+
381
+ if attributes.key?(:highlight_post_tag)
382
+ self.highlight_post_tag = attributes[:highlight_post_tag]
383
+ end
384
+
385
+ if attributes.key?(:highlight_pre_tag)
386
+ self.highlight_pre_tag = attributes[:highlight_pre_tag]
387
+ end
388
+
389
+ if attributes.key?(:ignore_plurals)
390
+ self.ignore_plurals = attributes[:ignore_plurals]
391
+ end
392
+
393
+ if attributes.key?(:max_facet_hits)
394
+ self.max_facet_hits = attributes[:max_facet_hits]
395
+ end
396
+
397
+ if attributes.key?(:min_proximity)
398
+ self.min_proximity = attributes[:min_proximity]
399
+ end
400
+
401
+ if attributes.key?(:min_word_sizefor1_typo)
402
+ self.min_word_sizefor1_typo = attributes[:min_word_sizefor1_typo]
403
+ end
404
+
405
+ if attributes.key?(:min_word_sizefor2_typos)
406
+ self.min_word_sizefor2_typos = attributes[:min_word_sizefor2_typos]
407
+ end
408
+
409
+ if attributes.key?(:natural_languages)
410
+ if (value = attributes[:natural_languages]).is_a?(Array)
411
+ self.natural_languages = value
412
+ end
413
+ end
414
+
415
+ if attributes.key?(:numeric_filters)
416
+ self.numeric_filters = attributes[:numeric_filters]
417
+ end
418
+
419
+ if attributes.key?(:optional_filters)
420
+ self.optional_filters = attributes[:optional_filters]
421
+ end
422
+
423
+ if attributes.key?(:optional_words)
424
+ self.optional_words = attributes[:optional_words]
425
+ end
426
+
427
+ if attributes.key?(:percentile_computation)
428
+ self.percentile_computation = attributes[:percentile_computation]
429
+ end
430
+
431
+ if attributes.key?(:personalization_impact)
432
+ self.personalization_impact = attributes[:personalization_impact]
433
+ end
434
+
435
+ if attributes.key?(:query_languages)
436
+ if (value = attributes[:query_languages]).is_a?(Array)
437
+ self.query_languages = value
438
+ end
439
+ end
440
+
441
+ if attributes.key?(:query_type)
442
+ self.query_type = attributes[:query_type]
443
+ end
444
+
445
+ if attributes.key?(:remove_stop_words)
446
+ self.remove_stop_words = attributes[:remove_stop_words]
447
+ end
448
+
449
+ if attributes.key?(:remove_words_if_no_results)
450
+ self.remove_words_if_no_results = attributes[:remove_words_if_no_results]
451
+ end
452
+
453
+ if attributes.key?(:replace_synonyms_in_highlight)
454
+ self.replace_synonyms_in_highlight = attributes[:replace_synonyms_in_highlight]
455
+ end
456
+
457
+ if attributes.key?(:response_fields)
458
+ if (value = attributes[:response_fields]).is_a?(Array)
459
+ self.response_fields = value
460
+ end
461
+ end
462
+
463
+ if attributes.key?(:restrict_highlight_and_snippet_arrays)
464
+ self.restrict_highlight_and_snippet_arrays = attributes[:restrict_highlight_and_snippet_arrays]
465
+ end
466
+
467
+ if attributes.key?(:restrict_searchable_attributes)
468
+ if (value = attributes[:restrict_searchable_attributes]).is_a?(Array)
469
+ self.restrict_searchable_attributes = value
470
+ end
471
+ end
472
+
473
+ if attributes.key?(:rule_contexts)
474
+ if (value = attributes[:rule_contexts]).is_a?(Array)
475
+ self.rule_contexts = value
476
+ end
477
+ end
478
+
479
+ if attributes.key?(:snippet_ellipsis_text)
480
+ self.snippet_ellipsis_text = attributes[:snippet_ellipsis_text]
481
+ end
482
+
483
+ if attributes.key?(:synonyms)
484
+ self.synonyms = attributes[:synonyms]
485
+ end
486
+
487
+ if attributes.key?(:typo_tolerance)
488
+ self.typo_tolerance = attributes[:typo_tolerance]
489
+ end
490
+ end
491
+
492
+ # Checks equality by comparing each attribute.
493
+ # @param [Object] Object to be compared
494
+ def ==(other)
495
+ return true if self.equal?(other)
496
+ self.class == other.class &&
497
+ advanced_syntax == other.advanced_syntax &&
498
+ advanced_syntax_features == other.advanced_syntax_features &&
499
+ allow_typos_on_numeric_tokens == other.allow_typos_on_numeric_tokens &&
500
+ alternatives_as_exact == other.alternatives_as_exact &&
501
+ analytics == other.analytics &&
502
+ attribute_criteria_computed_by_min_proximity == other.attribute_criteria_computed_by_min_proximity &&
503
+ attributes_to_highlight == other.attributes_to_highlight &&
504
+ attributes_to_retrieve == other.attributes_to_retrieve &&
505
+ attributes_to_snippet == other.attributes_to_snippet &&
506
+ click_analytics == other.click_analytics &&
507
+ decompound_query == other.decompound_query &&
508
+ disable_exact_on_attributes == other.disable_exact_on_attributes &&
509
+ disable_typo_tolerance_on_attributes == other.disable_typo_tolerance_on_attributes &&
510
+ distinct == other.distinct &&
511
+ enable_ab_test == other.enable_ab_test &&
512
+ enable_personalization == other.enable_personalization &&
513
+ enable_re_ranking == other.enable_re_ranking &&
514
+ enable_rules == other.enable_rules &&
515
+ exact_on_single_word_query == other.exact_on_single_word_query &&
516
+ facet_filters == other.facet_filters &&
517
+ filters == other.filters &&
518
+ get_ranking_info == other.get_ranking_info &&
519
+ highlight_post_tag == other.highlight_post_tag &&
520
+ highlight_pre_tag == other.highlight_pre_tag &&
521
+ ignore_plurals == other.ignore_plurals &&
522
+ max_facet_hits == other.max_facet_hits &&
523
+ min_proximity == other.min_proximity &&
524
+ min_word_sizefor1_typo == other.min_word_sizefor1_typo &&
525
+ min_word_sizefor2_typos == other.min_word_sizefor2_typos &&
526
+ natural_languages == other.natural_languages &&
527
+ numeric_filters == other.numeric_filters &&
528
+ optional_filters == other.optional_filters &&
529
+ optional_words == other.optional_words &&
530
+ percentile_computation == other.percentile_computation &&
531
+ personalization_impact == other.personalization_impact &&
532
+ query_languages == other.query_languages &&
533
+ query_type == other.query_type &&
534
+ remove_stop_words == other.remove_stop_words &&
535
+ remove_words_if_no_results == other.remove_words_if_no_results &&
536
+ replace_synonyms_in_highlight == other.replace_synonyms_in_highlight &&
537
+ response_fields == other.response_fields &&
538
+ restrict_highlight_and_snippet_arrays == other.restrict_highlight_and_snippet_arrays &&
539
+ restrict_searchable_attributes == other.restrict_searchable_attributes &&
540
+ rule_contexts == other.rule_contexts &&
541
+ snippet_ellipsis_text == other.snippet_ellipsis_text &&
542
+ synonyms == other.synonyms &&
543
+ typo_tolerance == other.typo_tolerance
544
+ end
545
+
546
+ # @see the `==` method
547
+ # @param [Object] Object to be compared
548
+ def eql?(other)
549
+ self == other
550
+ end
551
+
552
+ # Calculates hash code according to all attributes.
553
+ # @return [Integer] Hash code
554
+ def hash
555
+ [
556
+ advanced_syntax,
557
+ advanced_syntax_features,
558
+ allow_typos_on_numeric_tokens,
559
+ alternatives_as_exact,
560
+ analytics,
561
+ attribute_criteria_computed_by_min_proximity,
562
+ attributes_to_highlight,
563
+ attributes_to_retrieve,
564
+ attributes_to_snippet,
565
+ click_analytics,
566
+ decompound_query,
567
+ disable_exact_on_attributes,
568
+ disable_typo_tolerance_on_attributes,
569
+ distinct,
570
+ enable_ab_test,
571
+ enable_personalization,
572
+ enable_re_ranking,
573
+ enable_rules,
574
+ exact_on_single_word_query,
575
+ facet_filters,
576
+ filters,
577
+ get_ranking_info,
578
+ highlight_post_tag,
579
+ highlight_pre_tag,
580
+ ignore_plurals,
581
+ max_facet_hits,
582
+ min_proximity,
583
+ min_word_sizefor1_typo,
584
+ min_word_sizefor2_typos,
585
+ natural_languages,
586
+ numeric_filters,
587
+ optional_filters,
588
+ optional_words,
589
+ percentile_computation,
590
+ personalization_impact,
591
+ query_languages,
592
+ query_type,
593
+ remove_stop_words,
594
+ remove_words_if_no_results,
595
+ replace_synonyms_in_highlight,
596
+ response_fields,
597
+ restrict_highlight_and_snippet_arrays,
598
+ restrict_searchable_attributes,
599
+ rule_contexts,
600
+ snippet_ellipsis_text,
601
+ synonyms,
602
+ typo_tolerance
603
+ ].hash
604
+ end
605
+
606
+ # Builds the object from hash
607
+ # @param [Hash] attributes Model attributes in the form of hash
608
+ # @return [Object] Returns the model itself
609
+ def self.build_from_hash(attributes)
610
+ return nil unless attributes.is_a?(Hash)
611
+ attributes = attributes.transform_keys(&:to_sym)
612
+ transformed_hash = {}
613
+ types_mapping.each_pair do |key, type|
614
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
615
+ transformed_hash[key.to_sym] = nil
616
+ elsif type =~ /\AArray<(.*)>/i
617
+ # check to ensure the input is an array given that the attribute
618
+ # is documented as an array but the input is not
619
+ if attributes[attribute_map[key]].is_a?(Array)
620
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
621
+ _deserialize(::Regexp.last_match(1), v)
622
+ }
623
+ end
624
+ elsif !attributes[attribute_map[key]].nil?
625
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
626
+ end
627
+ end
628
+
629
+ new(transformed_hash)
630
+ end
631
+
632
+ # Deserializes the data based on type
633
+ # @param string type Data type
634
+ # @param string value Value to be deserialized
635
+ # @return [Object] Deserialized data
636
+ def self._deserialize(type, value)
637
+ case type.to_sym
638
+ when :Time
639
+ Time.parse(value)
640
+ when :Date
641
+ Date.parse(value)
642
+ when :String
643
+ value.to_s
644
+ when :Integer
645
+ value.to_i
646
+ when :Float
647
+ value.to_f
648
+ when :Boolean
649
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
650
+ true
651
+ else
652
+ false
653
+ end
654
+
655
+ when :Object
656
+ # generic object (usually a Hash), return directly
657
+ value
658
+ when /\AArray<(?<inner_type>.+)>\z/
659
+ inner_type = Regexp.last_match[:inner_type]
660
+ value.map { |v| _deserialize(inner_type, v) }
661
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
662
+ k_type = Regexp.last_match[:k_type]
663
+ v_type = Regexp.last_match[:v_type]
664
+ {}.tap do |hash|
665
+ value.each do |k, v|
666
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
667
+ end
668
+ end
669
+ # model
670
+ else
671
+ # models (e.g. Pet) or oneOf
672
+ klass = Algolia::Composition.const_get(type)
673
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
674
+ .build_from_hash(value)
675
+ end
676
+ end
677
+
678
+ # Returns the string representation of the object
679
+ # @return [String] String presentation of the object
680
+ def to_s
681
+ to_hash.to_s
682
+ end
683
+
684
+ # to_body is an alias to to_hash (backward compatibility)
685
+ # @return [Hash] Returns the object in the form of hash
686
+ def to_body
687
+ to_hash
688
+ end
689
+
690
+ def to_json(*_args)
691
+ to_hash.to_json
692
+ end
693
+
694
+ # Returns the object in the form of hash
695
+ # @return [Hash] Returns the object in the form of hash
696
+ def to_hash
697
+ hash = {}
698
+ self.class.attribute_map.each_pair do |attr, param|
699
+ value = send(attr)
700
+ if value.nil?
701
+ is_nullable = self.class.openapi_nullable.include?(attr)
702
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
703
+ end
704
+
705
+ hash[param] = _to_hash(value)
706
+ end
707
+
708
+ hash
709
+ end
710
+
711
+ # Outputs non-array value in the form of hash
712
+ # For object, use to_hash. Otherwise, just return the value
713
+ # @param [Object] value Any valid value
714
+ # @return [Hash] Returns the value in the form of hash
715
+ def _to_hash(value)
716
+ if value.is_a?(Array)
717
+ value.compact.map { |v| _to_hash(v) }
718
+ elsif value.is_a?(Hash)
719
+ {}.tap do |hash|
720
+ value.each { |k, v| hash[k] = _to_hash(v) }
721
+ end
722
+ elsif value.respond_to?(:to_hash)
723
+ value.to_hash
724
+ else
725
+ value
726
+ end
727
+ end
728
+
729
+ end
730
+
731
+ end
732
+ end