algolia 3.8.0 → 3.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/search_client.rb +2 -2
- data/lib/algolia/models/recommend/fallback_params.rb +19 -22
- data/lib/algolia/models/recommend/inside_bounding_box.rb +108 -0
- data/lib/algolia/models/recommend/optional_words.rb +108 -0
- data/lib/algolia/models/recommend/recommend_search_params.rb +19 -22
- data/lib/algolia/models/recommend/recommendations_request.rb +0 -1
- data/lib/algolia/models/search/browse_params_object.rb +8 -22
- data/lib/algolia/models/search/consequence_params.rb +8 -22
- data/lib/algolia/models/search/delete_by_params.rb +5 -6
- data/lib/algolia/models/search/index_settings.rb +16 -17
- data/lib/algolia/models/search/inside_bounding_box.rb +108 -0
- data/lib/algolia/models/search/optional_words.rb +108 -0
- data/lib/algolia/models/search/search_for_facets.rb +19 -22
- data/lib/algolia/models/search/search_for_hits.rb +8 -22
- data/lib/algolia/models/search/search_params_object.rb +8 -22
- data/lib/algolia/models/search/settings_response.rb +16 -17
- data/lib/algolia/version.rb +1 -1
- metadata +6 -4
- data/lib/algolia/models/recommend/recommended_for_you_model.rb +0 -31
- data/lib/algolia/models/recommend/recommended_for_you_query.rb +0 -273
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c51a14703310430c09094a863959ee54716168cdc77fdb576bcd0f845c38a6d4
|
4
|
+
data.tar.gz: 64a6763014cc2d405856a8626bcd044e130160255e5c17c7fbd6cc41909418a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1866d02c45e8b6399a1a616ba4f3b918db7be3f6b0b526ebcf97316bcdd11beefca56201ec73024af740bb526ad13e39354e199771550df1ae672c1d6e24f332
|
7
|
+
data.tar.gz: a8aa53de27a0ba088fa4e1ba725e21b631a6a70f136287772f6e887d29d10140df3c5d2e588d586b4d9f9d03dfbc59a79b3e113c4569706588ee3885a1f5e5c0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [3.8.1](https://github.com/algolia/algoliasearch-client-ruby/compare/3.8.0...3.8.1)
|
2
|
+
|
3
|
+
- [36d583e35](https://github.com/algolia/api-clients-automation/commit/36d583e35) fix(specs): make the searchParams compatible with v4 ([#4108](https://github.com/algolia/api-clients-automation/pull/4108)) by [@millotp](https://github.com/millotp/)
|
4
|
+
- [996ba5036](https://github.com/algolia/api-clients-automation/commit/996ba5036) fix(specs): remove private beta endpoint from recommend ([#4110](https://github.com/algolia/api-clients-automation/pull/4110)) by [@shortcuts](https://github.com/shortcuts/)
|
5
|
+
|
1
6
|
## [3.8.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.7.1...3.8.0)
|
2
7
|
|
3
8
|
- [4c73f4c9a](https://github.com/algolia/api-clients-automation/commit/4c73f4c9a) feat(specs): add estimate path and responses ([#4057](https://github.com/algolia/api-clients-automation/pull/4057)) by [@cdhawke](https://github.com/cdhawke/)
|
data/Gemfile.lock
CHANGED
@@ -860,10 +860,10 @@ module Algolia
|
|
860
860
|
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
861
861
|
# @param delete_by_params [DeleteByParams] (required)
|
862
862
|
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
863
|
-
# @return [
|
863
|
+
# @return [UpdatedAtResponse]
|
864
864
|
def delete_by(index_name, delete_by_params, request_options = {})
|
865
865
|
response = delete_by_with_http_info(index_name, delete_by_params, request_options)
|
866
|
-
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::
|
866
|
+
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdatedAtResponse")
|
867
867
|
end
|
868
868
|
|
869
869
|
# Deletes an index and all its settings. - Deleting an index doesn't delete its analytics data. - If you try to delete a non-existing index, the operation is ignored without warning. - If the index you want to delete has replica indices, the replicas become independent indices. - If the index you want to delete is a replica index, you must first unlink it from its primary index before you can delete it. For more information, see [Delete replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/deleting-replicas/).
|
@@ -45,7 +45,6 @@ module Algolia
|
|
45
45
|
# Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.
|
46
46
|
attr_accessor :minimum_around_radius
|
47
47
|
|
48
|
-
# 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).
|
49
48
|
attr_accessor :inside_bounding_box
|
50
49
|
|
51
50
|
# 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`.
|
@@ -138,6 +137,9 @@ module Algolia
|
|
138
137
|
# 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.
|
139
138
|
attr_accessor :attribute_for_distinct
|
140
139
|
|
140
|
+
# 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).
|
141
|
+
attr_accessor :max_facet_hits
|
142
|
+
|
141
143
|
# 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.
|
142
144
|
attr_accessor :attributes_to_retrieve
|
143
145
|
|
@@ -202,7 +204,6 @@ module Algolia
|
|
202
204
|
# Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported.
|
203
205
|
attr_accessor :advanced_syntax
|
204
206
|
|
205
|
-
# 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).
|
206
207
|
attr_accessor :optional_words
|
207
208
|
|
208
209
|
# 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.
|
@@ -227,9 +228,6 @@ module Algolia
|
|
227
228
|
# 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.
|
228
229
|
attr_accessor :response_fields
|
229
230
|
|
230
|
-
# 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).
|
231
|
-
attr_accessor :max_facet_hits
|
232
|
-
|
233
231
|
# Maximum number of facet values to return for each facet.
|
234
232
|
attr_accessor :max_values_per_facet
|
235
233
|
|
@@ -295,6 +293,7 @@ module Algolia
|
|
295
293
|
:user_data => :userData,
|
296
294
|
:custom_normalization => :customNormalization,
|
297
295
|
:attribute_for_distinct => :attributeForDistinct,
|
296
|
+
:max_facet_hits => :maxFacetHits,
|
298
297
|
:attributes_to_retrieve => :attributesToRetrieve,
|
299
298
|
:ranking => :ranking,
|
300
299
|
:relevancy_strictness => :relevancyStrictness,
|
@@ -327,7 +326,6 @@ module Algolia
|
|
327
326
|
:replace_synonyms_in_highlight => :replaceSynonymsInHighlight,
|
328
327
|
:min_proximity => :minProximity,
|
329
328
|
:response_fields => :responseFields,
|
330
|
-
:max_facet_hits => :maxFacetHits,
|
331
329
|
:max_values_per_facet => :maxValuesPerFacet,
|
332
330
|
:sort_facet_values_by => :sortFacetValuesBy,
|
333
331
|
:attribute_criteria_computed_by_min_proximity => :attributeCriteriaComputedByMinProximity,
|
@@ -360,7 +358,7 @@ module Algolia
|
|
360
358
|
:around_radius => :"AroundRadius",
|
361
359
|
:around_precision => :"AroundPrecision",
|
362
360
|
:minimum_around_radius => :"Integer",
|
363
|
-
:inside_bounding_box => :"
|
361
|
+
:inside_bounding_box => :"InsideBoundingBox",
|
364
362
|
:inside_polygon => :"Array<Array<Float>>",
|
365
363
|
:natural_languages => :"Array<SupportedLanguage>",
|
366
364
|
:rule_contexts => :"Array<String>",
|
@@ -391,6 +389,7 @@ module Algolia
|
|
391
389
|
:user_data => :"Object",
|
392
390
|
:custom_normalization => :"Hash<String, Hash<String, String>>",
|
393
391
|
:attribute_for_distinct => :"String",
|
392
|
+
:max_facet_hits => :"Integer",
|
394
393
|
:attributes_to_retrieve => :"Array<String>",
|
395
394
|
:ranking => :"Array<String>",
|
396
395
|
:relevancy_strictness => :"Integer",
|
@@ -414,7 +413,7 @@ module Algolia
|
|
414
413
|
:query_type => :"QueryType",
|
415
414
|
:remove_words_if_no_results => :"RemoveWordsIfNoResults",
|
416
415
|
:advanced_syntax => :"Boolean",
|
417
|
-
:optional_words => :"
|
416
|
+
:optional_words => :"OptionalWords",
|
418
417
|
:disable_exact_on_attributes => :"Array<String>",
|
419
418
|
:exact_on_single_word_query => :"ExactOnSingleWordQuery",
|
420
419
|
:alternatives_as_exact => :"Array<AlternativesAsExact>",
|
@@ -423,7 +422,6 @@ module Algolia
|
|
423
422
|
:replace_synonyms_in_highlight => :"Boolean",
|
424
423
|
:min_proximity => :"Integer",
|
425
424
|
:response_fields => :"Array<String>",
|
426
|
-
:max_facet_hits => :"Integer",
|
427
425
|
:max_values_per_facet => :"Integer",
|
428
426
|
:sort_facet_values_by => :"String",
|
429
427
|
:attribute_criteria_computed_by_min_proximity => :"Boolean",
|
@@ -436,7 +434,10 @@ module Algolia
|
|
436
434
|
# List of attributes with nullable: true
|
437
435
|
def self.openapi_nullable
|
438
436
|
Set.new(
|
439
|
-
[
|
437
|
+
[
|
438
|
+
:inside_bounding_box,
|
439
|
+
:optional_words
|
440
|
+
]
|
440
441
|
)
|
441
442
|
end
|
442
443
|
|
@@ -535,9 +536,7 @@ module Algolia
|
|
535
536
|
end
|
536
537
|
|
537
538
|
if attributes.key?(:inside_bounding_box)
|
538
|
-
|
539
|
-
self.inside_bounding_box = value
|
540
|
-
end
|
539
|
+
self.inside_bounding_box = attributes[:inside_bounding_box]
|
541
540
|
end
|
542
541
|
|
543
542
|
if attributes.key?(:inside_polygon)
|
@@ -690,6 +689,10 @@ module Algolia
|
|
690
689
|
self.attribute_for_distinct = attributes[:attribute_for_distinct]
|
691
690
|
end
|
692
691
|
|
692
|
+
if attributes.key?(:max_facet_hits)
|
693
|
+
self.max_facet_hits = attributes[:max_facet_hits]
|
694
|
+
end
|
695
|
+
|
693
696
|
if attributes.key?(:attributes_to_retrieve)
|
694
697
|
if (value = attributes[:attributes_to_retrieve]).is_a?(Array)
|
695
698
|
self.attributes_to_retrieve = value
|
@@ -795,9 +798,7 @@ module Algolia
|
|
795
798
|
end
|
796
799
|
|
797
800
|
if attributes.key?(:optional_words)
|
798
|
-
|
799
|
-
self.optional_words = value
|
800
|
-
end
|
801
|
+
self.optional_words = attributes[:optional_words]
|
801
802
|
end
|
802
803
|
|
803
804
|
if attributes.key?(:disable_exact_on_attributes)
|
@@ -840,10 +841,6 @@ module Algolia
|
|
840
841
|
end
|
841
842
|
end
|
842
843
|
|
843
|
-
if attributes.key?(:max_facet_hits)
|
844
|
-
self.max_facet_hits = attributes[:max_facet_hits]
|
845
|
-
end
|
846
|
-
|
847
844
|
if attributes.key?(:max_values_per_facet)
|
848
845
|
self.max_values_per_facet = attributes[:max_values_per_facet]
|
849
846
|
end
|
@@ -920,6 +917,7 @@ module Algolia
|
|
920
917
|
user_data == other.user_data &&
|
921
918
|
custom_normalization == other.custom_normalization &&
|
922
919
|
attribute_for_distinct == other.attribute_for_distinct &&
|
920
|
+
max_facet_hits == other.max_facet_hits &&
|
923
921
|
attributes_to_retrieve == other.attributes_to_retrieve &&
|
924
922
|
ranking == other.ranking &&
|
925
923
|
relevancy_strictness == other.relevancy_strictness &&
|
@@ -952,7 +950,6 @@ module Algolia
|
|
952
950
|
replace_synonyms_in_highlight == other.replace_synonyms_in_highlight &&
|
953
951
|
min_proximity == other.min_proximity &&
|
954
952
|
response_fields == other.response_fields &&
|
955
|
-
max_facet_hits == other.max_facet_hits &&
|
956
953
|
max_values_per_facet == other.max_values_per_facet &&
|
957
954
|
sort_facet_values_by == other.sort_facet_values_by &&
|
958
955
|
attribute_criteria_computed_by_min_proximity == other.attribute_criteria_computed_by_min_proximity &&
|
@@ -1017,6 +1014,7 @@ module Algolia
|
|
1017
1014
|
user_data,
|
1018
1015
|
custom_normalization,
|
1019
1016
|
attribute_for_distinct,
|
1017
|
+
max_facet_hits,
|
1020
1018
|
attributes_to_retrieve,
|
1021
1019
|
ranking,
|
1022
1020
|
relevancy_strictness,
|
@@ -1049,7 +1047,6 @@ module Algolia
|
|
1049
1047
|
replace_synonyms_in_highlight,
|
1050
1048
|
min_proximity,
|
1051
1049
|
response_fields,
|
1052
|
-
max_facet_hits,
|
1053
1050
|
max_values_per_facet,
|
1054
1051
|
sort_facet_values_by,
|
1055
1052
|
attribute_criteria_computed_by_min_proximity,
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# 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.
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "time"
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Recommend
|
8
|
+
module InsideBoundingBox
|
9
|
+
class << self
|
10
|
+
# List of class defined in oneOf (OpenAPI v3)
|
11
|
+
def openapi_one_of
|
12
|
+
[
|
13
|
+
:"Array<Array<Float>>",
|
14
|
+
:"String"
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
# Builds the object
|
19
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
20
|
+
# @return [Object] Returns the model or the data itself
|
21
|
+
def build(data)
|
22
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
23
|
+
# Note:
|
24
|
+
# - We do not attempt to check whether exactly one item matches.
|
25
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
26
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
27
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
28
|
+
# - TODO: logging when debugging is set.
|
29
|
+
openapi_one_of.each do |klass|
|
30
|
+
begin
|
31
|
+
# "nullable: true"
|
32
|
+
next if klass == :AnyType
|
33
|
+
typed_data = find_and_cast_into_type(klass, data)
|
34
|
+
return typed_data if typed_data
|
35
|
+
# rescue all errors so we keep iterating even if the current item lookup raises
|
36
|
+
rescue
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
SchemaMismatchError = Class.new(StandardError)
|
46
|
+
|
47
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
48
|
+
def find_and_cast_into_type(klass, data)
|
49
|
+
return if data.nil?
|
50
|
+
|
51
|
+
case klass.to_s
|
52
|
+
when "Boolean"
|
53
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
54
|
+
when "Float"
|
55
|
+
return data if data.instance_of?(Float)
|
56
|
+
when "Integer"
|
57
|
+
return data if data.instance_of?(Integer)
|
58
|
+
when "Time"
|
59
|
+
return Time.parse(data)
|
60
|
+
when "Date"
|
61
|
+
return Date.parse(data)
|
62
|
+
when "String"
|
63
|
+
return data if data.instance_of?(String)
|
64
|
+
# "type: object"
|
65
|
+
when "Object"
|
66
|
+
return data if data.instance_of?(Hash)
|
67
|
+
# "type: array"
|
68
|
+
when /\AArray<(?<sub_type>.+)>\z/
|
69
|
+
if data.instance_of?(Array)
|
70
|
+
sub_type = Regexp.last_match[:sub_type]
|
71
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
72
|
+
end
|
73
|
+
# "type: object" with "additionalProperties: { ... }"
|
74
|
+
when /\AHash<String, (?<sub_type>.+)>\z/
|
75
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
76
|
+
sub_type = Regexp.last_match[:sub_type]
|
77
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
78
|
+
end
|
79
|
+
# model
|
80
|
+
else
|
81
|
+
const = Algolia::Recommend.const_get(klass)
|
82
|
+
if const
|
83
|
+
if const.respond_to?(:openapi_one_of)
|
84
|
+
# nested oneOf model
|
85
|
+
model = const.build(data)
|
86
|
+
elsif const.respond_to?(:acceptable_attributes)
|
87
|
+
# raise if data contains keys that are not known to the model
|
88
|
+
raise unless (data.keys - const.acceptable_attributes).empty?
|
89
|
+
model = const.build_from_hash(data)
|
90
|
+
else
|
91
|
+
# maybe it's an enum
|
92
|
+
model = const.build_from_hash(data)
|
93
|
+
end
|
94
|
+
|
95
|
+
return model if model
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# if no match by now, raise
|
100
|
+
raise
|
101
|
+
rescue
|
102
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# 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.
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "time"
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Recommend
|
8
|
+
module OptionalWords
|
9
|
+
class << self
|
10
|
+
# List of class defined in oneOf (OpenAPI v3)
|
11
|
+
def openapi_one_of
|
12
|
+
[
|
13
|
+
:"Array<String>",
|
14
|
+
:"String"
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
# Builds the object
|
19
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
20
|
+
# @return [Object] Returns the model or the data itself
|
21
|
+
def build(data)
|
22
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
23
|
+
# Note:
|
24
|
+
# - We do not attempt to check whether exactly one item matches.
|
25
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
26
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
27
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
28
|
+
# - TODO: logging when debugging is set.
|
29
|
+
openapi_one_of.each do |klass|
|
30
|
+
begin
|
31
|
+
# "nullable: true"
|
32
|
+
next if klass == :AnyType
|
33
|
+
typed_data = find_and_cast_into_type(klass, data)
|
34
|
+
return typed_data if typed_data
|
35
|
+
# rescue all errors so we keep iterating even if the current item lookup raises
|
36
|
+
rescue
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
SchemaMismatchError = Class.new(StandardError)
|
46
|
+
|
47
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
48
|
+
def find_and_cast_into_type(klass, data)
|
49
|
+
return if data.nil?
|
50
|
+
|
51
|
+
case klass.to_s
|
52
|
+
when "Boolean"
|
53
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
54
|
+
when "Float"
|
55
|
+
return data if data.instance_of?(Float)
|
56
|
+
when "Integer"
|
57
|
+
return data if data.instance_of?(Integer)
|
58
|
+
when "Time"
|
59
|
+
return Time.parse(data)
|
60
|
+
when "Date"
|
61
|
+
return Date.parse(data)
|
62
|
+
when "String"
|
63
|
+
return data if data.instance_of?(String)
|
64
|
+
# "type: object"
|
65
|
+
when "Object"
|
66
|
+
return data if data.instance_of?(Hash)
|
67
|
+
# "type: array"
|
68
|
+
when /\AArray<(?<sub_type>.+)>\z/
|
69
|
+
if data.instance_of?(Array)
|
70
|
+
sub_type = Regexp.last_match[:sub_type]
|
71
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
72
|
+
end
|
73
|
+
# "type: object" with "additionalProperties: { ... }"
|
74
|
+
when /\AHash<String, (?<sub_type>.+)>\z/
|
75
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
76
|
+
sub_type = Regexp.last_match[:sub_type]
|
77
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
78
|
+
end
|
79
|
+
# model
|
80
|
+
else
|
81
|
+
const = Algolia::Recommend.const_get(klass)
|
82
|
+
if const
|
83
|
+
if const.respond_to?(:openapi_one_of)
|
84
|
+
# nested oneOf model
|
85
|
+
model = const.build(data)
|
86
|
+
elsif const.respond_to?(:acceptable_attributes)
|
87
|
+
# raise if data contains keys that are not known to the model
|
88
|
+
raise unless (data.keys - const.acceptable_attributes).empty?
|
89
|
+
model = const.build_from_hash(data)
|
90
|
+
else
|
91
|
+
# maybe it's an enum
|
92
|
+
model = const.build_from_hash(data)
|
93
|
+
end
|
94
|
+
|
95
|
+
return model if model
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# if no match by now, raise
|
100
|
+
raise
|
101
|
+
rescue
|
102
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -46,7 +46,6 @@ module Algolia
|
|
46
46
|
# Minimum radius (in meters) for a search around a location when `aroundRadius` isn't set.
|
47
47
|
attr_accessor :minimum_around_radius
|
48
48
|
|
49
|
-
# 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).
|
50
49
|
attr_accessor :inside_bounding_box
|
51
50
|
|
52
51
|
# 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`.
|
@@ -139,6 +138,9 @@ module Algolia
|
|
139
138
|
# 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.
|
140
139
|
attr_accessor :attribute_for_distinct
|
141
140
|
|
141
|
+
# 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).
|
142
|
+
attr_accessor :max_facet_hits
|
143
|
+
|
142
144
|
# 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.
|
143
145
|
attr_accessor :attributes_to_retrieve
|
144
146
|
|
@@ -203,7 +205,6 @@ module Algolia
|
|
203
205
|
# Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported.
|
204
206
|
attr_accessor :advanced_syntax
|
205
207
|
|
206
|
-
# 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).
|
207
208
|
attr_accessor :optional_words
|
208
209
|
|
209
210
|
# 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.
|
@@ -228,9 +229,6 @@ module Algolia
|
|
228
229
|
# 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.
|
229
230
|
attr_accessor :response_fields
|
230
231
|
|
231
|
-
# 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).
|
232
|
-
attr_accessor :max_facet_hits
|
233
|
-
|
234
232
|
# Maximum number of facet values to return for each facet.
|
235
233
|
attr_accessor :max_values_per_facet
|
236
234
|
|
@@ -296,6 +294,7 @@ module Algolia
|
|
296
294
|
:user_data => :userData,
|
297
295
|
:custom_normalization => :customNormalization,
|
298
296
|
:attribute_for_distinct => :attributeForDistinct,
|
297
|
+
:max_facet_hits => :maxFacetHits,
|
299
298
|
:attributes_to_retrieve => :attributesToRetrieve,
|
300
299
|
:ranking => :ranking,
|
301
300
|
:relevancy_strictness => :relevancyStrictness,
|
@@ -328,7 +327,6 @@ module Algolia
|
|
328
327
|
:replace_synonyms_in_highlight => :replaceSynonymsInHighlight,
|
329
328
|
:min_proximity => :minProximity,
|
330
329
|
:response_fields => :responseFields,
|
331
|
-
:max_facet_hits => :maxFacetHits,
|
332
330
|
:max_values_per_facet => :maxValuesPerFacet,
|
333
331
|
:sort_facet_values_by => :sortFacetValuesBy,
|
334
332
|
:attribute_criteria_computed_by_min_proximity => :attributeCriteriaComputedByMinProximity,
|
@@ -361,7 +359,7 @@ module Algolia
|
|
361
359
|
:around_radius => :"AroundRadius",
|
362
360
|
:around_precision => :"AroundPrecision",
|
363
361
|
:minimum_around_radius => :"Integer",
|
364
|
-
:inside_bounding_box => :"
|
362
|
+
:inside_bounding_box => :"InsideBoundingBox",
|
365
363
|
:inside_polygon => :"Array<Array<Float>>",
|
366
364
|
:natural_languages => :"Array<SupportedLanguage>",
|
367
365
|
:rule_contexts => :"Array<String>",
|
@@ -392,6 +390,7 @@ module Algolia
|
|
392
390
|
:user_data => :"Object",
|
393
391
|
:custom_normalization => :"Hash<String, Hash<String, String>>",
|
394
392
|
:attribute_for_distinct => :"String",
|
393
|
+
:max_facet_hits => :"Integer",
|
395
394
|
:attributes_to_retrieve => :"Array<String>",
|
396
395
|
:ranking => :"Array<String>",
|
397
396
|
:relevancy_strictness => :"Integer",
|
@@ -415,7 +414,7 @@ module Algolia
|
|
415
414
|
:query_type => :"QueryType",
|
416
415
|
:remove_words_if_no_results => :"RemoveWordsIfNoResults",
|
417
416
|
:advanced_syntax => :"Boolean",
|
418
|
-
:optional_words => :"
|
417
|
+
:optional_words => :"OptionalWords",
|
419
418
|
:disable_exact_on_attributes => :"Array<String>",
|
420
419
|
:exact_on_single_word_query => :"ExactOnSingleWordQuery",
|
421
420
|
:alternatives_as_exact => :"Array<AlternativesAsExact>",
|
@@ -424,7 +423,6 @@ module Algolia
|
|
424
423
|
:replace_synonyms_in_highlight => :"Boolean",
|
425
424
|
:min_proximity => :"Integer",
|
426
425
|
:response_fields => :"Array<String>",
|
427
|
-
:max_facet_hits => :"Integer",
|
428
426
|
:max_values_per_facet => :"Integer",
|
429
427
|
:sort_facet_values_by => :"String",
|
430
428
|
:attribute_criteria_computed_by_min_proximity => :"Boolean",
|
@@ -437,7 +435,10 @@ module Algolia
|
|
437
435
|
# List of attributes with nullable: true
|
438
436
|
def self.openapi_nullable
|
439
437
|
Set.new(
|
440
|
-
[
|
438
|
+
[
|
439
|
+
:inside_bounding_box,
|
440
|
+
:optional_words
|
441
|
+
]
|
441
442
|
)
|
442
443
|
end
|
443
444
|
|
@@ -538,9 +539,7 @@ module Algolia
|
|
538
539
|
end
|
539
540
|
|
540
541
|
if attributes.key?(:inside_bounding_box)
|
541
|
-
|
542
|
-
self.inside_bounding_box = value
|
543
|
-
end
|
542
|
+
self.inside_bounding_box = attributes[:inside_bounding_box]
|
544
543
|
end
|
545
544
|
|
546
545
|
if attributes.key?(:inside_polygon)
|
@@ -693,6 +692,10 @@ module Algolia
|
|
693
692
|
self.attribute_for_distinct = attributes[:attribute_for_distinct]
|
694
693
|
end
|
695
694
|
|
695
|
+
if attributes.key?(:max_facet_hits)
|
696
|
+
self.max_facet_hits = attributes[:max_facet_hits]
|
697
|
+
end
|
698
|
+
|
696
699
|
if attributes.key?(:attributes_to_retrieve)
|
697
700
|
if (value = attributes[:attributes_to_retrieve]).is_a?(Array)
|
698
701
|
self.attributes_to_retrieve = value
|
@@ -798,9 +801,7 @@ module Algolia
|
|
798
801
|
end
|
799
802
|
|
800
803
|
if attributes.key?(:optional_words)
|
801
|
-
|
802
|
-
self.optional_words = value
|
803
|
-
end
|
804
|
+
self.optional_words = attributes[:optional_words]
|
804
805
|
end
|
805
806
|
|
806
807
|
if attributes.key?(:disable_exact_on_attributes)
|
@@ -843,10 +844,6 @@ module Algolia
|
|
843
844
|
end
|
844
845
|
end
|
845
846
|
|
846
|
-
if attributes.key?(:max_facet_hits)
|
847
|
-
self.max_facet_hits = attributes[:max_facet_hits]
|
848
|
-
end
|
849
|
-
|
850
847
|
if attributes.key?(:max_values_per_facet)
|
851
848
|
self.max_values_per_facet = attributes[:max_values_per_facet]
|
852
849
|
end
|
@@ -923,6 +920,7 @@ module Algolia
|
|
923
920
|
user_data == other.user_data &&
|
924
921
|
custom_normalization == other.custom_normalization &&
|
925
922
|
attribute_for_distinct == other.attribute_for_distinct &&
|
923
|
+
max_facet_hits == other.max_facet_hits &&
|
926
924
|
attributes_to_retrieve == other.attributes_to_retrieve &&
|
927
925
|
ranking == other.ranking &&
|
928
926
|
relevancy_strictness == other.relevancy_strictness &&
|
@@ -955,7 +953,6 @@ module Algolia
|
|
955
953
|
replace_synonyms_in_highlight == other.replace_synonyms_in_highlight &&
|
956
954
|
min_proximity == other.min_proximity &&
|
957
955
|
response_fields == other.response_fields &&
|
958
|
-
max_facet_hits == other.max_facet_hits &&
|
959
956
|
max_values_per_facet == other.max_values_per_facet &&
|
960
957
|
sort_facet_values_by == other.sort_facet_values_by &&
|
961
958
|
attribute_criteria_computed_by_min_proximity == other.attribute_criteria_computed_by_min_proximity &&
|
@@ -1020,6 +1017,7 @@ module Algolia
|
|
1020
1017
|
user_data,
|
1021
1018
|
custom_normalization,
|
1022
1019
|
attribute_for_distinct,
|
1020
|
+
max_facet_hits,
|
1023
1021
|
attributes_to_retrieve,
|
1024
1022
|
ranking,
|
1025
1023
|
relevancy_strictness,
|
@@ -1052,7 +1050,6 @@ module Algolia
|
|
1052
1050
|
replace_synonyms_in_highlight,
|
1053
1051
|
min_proximity,
|
1054
1052
|
response_fields,
|
1055
|
-
max_facet_hits,
|
1056
1053
|
max_values_per_facet,
|
1057
1054
|
sort_facet_values_by,
|
1058
1055
|
attribute_criteria_computed_by_min_proximity,
|