Class: Algolia::Composition::Params

Inherits:
Object
  • Object
show all
Defined in:
lib/algolia/models/composition/params.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Params

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/algolia/models/composition/params.rb', line 163

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Params` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      raise(
        ArgumentError,
        "`#{k}` is not a valid attribute in `Algolia::Params`. Please check the name to make sure it's valid. List of attributes: " +
          self.class.attribute_map.keys.inspect
      )
    end

    h[k.to_sym] = v
  }

  if attributes.key?(:query)
    self.query = attributes[:query]
  end

  if attributes.key?(:filters)
    self.filters = attributes[:filters]
  end

  if attributes.key?(:page)
    self.page = attributes[:page]
  end

  if attributes.key?(:get_ranking_info)
    self.get_ranking_info = attributes[:get_ranking_info]
  end

  if attributes.key?(:relevancy_strictness)
    self.relevancy_strictness = attributes[:relevancy_strictness]
  end

  if attributes.key?(:facet_filters)
    self.facet_filters = attributes[:facet_filters]
  end

  if attributes.key?(:optional_filters)
    self.optional_filters = attributes[:optional_filters]
  end

  if attributes.key?(:numeric_filters)
    self.numeric_filters = attributes[:numeric_filters]
  end

  if attributes.key?(:hits_per_page)
    self.hits_per_page = attributes[:hits_per_page]
  end

  if attributes.key?(:around_lat_lng)
    self.around_lat_lng = attributes[:around_lat_lng]
  end

  if attributes.key?(:around_lat_lng_via_ip)
    self.around_lat_lng_via_ip = attributes[:around_lat_lng_via_ip]
  end

  if attributes.key?(:around_radius)
    self.around_radius = attributes[:around_radius]
  end

  if attributes.key?(:around_precision)
    self.around_precision = attributes[:around_precision]
  end

  if attributes.key?(:minimum_around_radius)
    self.minimum_around_radius = attributes[:minimum_around_radius]
  end

  if attributes.key?(:inside_bounding_box)
    self.inside_bounding_box = attributes[:inside_bounding_box]
  end

  if attributes.key?(:inside_polygon)
    if (value = attributes[:inside_polygon]).is_a?(Array)
      self.inside_polygon = value
    end
  end

  if attributes.key?(:query_languages)
    if (value = attributes[:query_languages]).is_a?(Array)
      self.query_languages = value
    end
  end

  if attributes.key?(:natural_languages)
    if (value = attributes[:natural_languages]).is_a?(Array)
      self.natural_languages = value
    end
  end

  if attributes.key?(:enable_rules)
    self.enable_rules = attributes[:enable_rules]
  end

  if attributes.key?(:rule_contexts)
    if (value = attributes[:rule_contexts]).is_a?(Array)
      self.rule_contexts = value
    end
  end

  if attributes.key?(:user_token)
    self.user_token = attributes[:user_token]
  end

  if attributes.key?(:click_analytics)
    self.click_analytics = attributes[:click_analytics]
  end

  if attributes.key?(:analytics)
    self.analytics = attributes[:analytics]
  end

  if attributes.key?(:analytics_tags)
    if (value = attributes[:analytics_tags]).is_a?(Array)
      self.analytics_tags = value
    end
  end

  if attributes.key?(:enable_ab_test)
    self.enable_ab_test = attributes[:enable_ab_test]
  end

  if attributes.key?(:enable_re_ranking)
    self.enable_re_ranking = attributes[:enable_re_ranking]
  end

  if attributes.key?(:injected_items)
    if (value = attributes[:injected_items]).is_a?(Hash)
      self.injected_items = value
    end
  end
end

Instance Attribute Details

#analyticsObject

Whether this search will be included in Analytics.



72
73
74
# File 'lib/algolia/models/composition/params.rb', line 72

def analytics
  @analytics
end

#analytics_tagsObject

Tags to apply to the query for [segmenting analytics data](www.algolia.com/doc/guides/search-analytics/guides/segments/).



75
76
77
# File 'lib/algolia/models/composition/params.rb', line 75

def analytics_tags
  @analytics_tags
end

#around_lat_lngObject

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`.



36
37
38
# File 'lib/algolia/models/composition/params.rb', line 36

def around_lat_lng
  @around_lat_lng
end

#around_lat_lng_via_ipObject

Whether to obtain the coordinates from the request’s IP address.



39
40
41
# File 'lib/algolia/models/composition/params.rb', line 39

def around_lat_lng_via_ip
  @around_lat_lng_via_ip
end

#around_precisionObject

Returns the value of attribute around_precision.



43
44
45
# File 'lib/algolia/models/composition/params.rb', line 43

def around_precision
  @around_precision
end

#around_radiusObject

Returns the value of attribute around_radius.



41
42
43
# File 'lib/algolia/models/composition/params.rb', line 41

def around_radius
  @around_radius
end

#click_analyticsObject

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](www.algolia.com/guides/sending-events/getting-started/).



69
70
71
# File 'lib/algolia/models/composition/params.rb', line 69

def click_analytics
  @click_analytics
end

#enable_ab_testObject

Whether to enable index level A/B testing for this run request. If the composition mixes multiple indices, the A/B test is ignored.



78
79
80
# File 'lib/algolia/models/composition/params.rb', line 78

def enable_ab_test
  @enable_ab_test
end

#enable_re_rankingObject

Whether this search will use [Dynamic Re-Ranking](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.



81
82
83
# File 'lib/algolia/models/composition/params.rb', line 81

def enable_re_ranking
  @enable_re_ranking
end

#enable_rulesObject

Whether to enable composition rules.



60
61
62
# File 'lib/algolia/models/composition/params.rb', line 60

def enable_rules
  @enable_rules
end

#facet_filtersObject

Returns the value of attribute facet_filters.



26
27
28
# File 'lib/algolia/models/composition/params.rb', line 26

def facet_filters
  @facet_filters
end

#filtersObject

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](www.algolia.com/doc/guides/managing-results/refine-results/filtering/).



15
16
17
# File 'lib/algolia/models/composition/params.rb', line 15

def filters
  @filters
end

#get_ranking_infoObject

Whether the run response should include detailed ranking information.



21
22
23
# File 'lib/algolia/models/composition/params.rb', line 21

def get_ranking_info
  @get_ranking_info
end

#hits_per_pageObject

Number of hits per page.



33
34
35
# File 'lib/algolia/models/composition/params.rb', line 33

def hits_per_page
  @hits_per_page
end

#injected_itemsObject

A list of extenrally injected objectID groups into from an external source.



84
85
86
# File 'lib/algolia/models/composition/params.rb', line 84

def injected_items
  @injected_items
end

#inside_bounding_boxObject

Returns the value of attribute inside_bounding_box.



48
49
50
# File 'lib/algolia/models/composition/params.rb', line 48

def inside_bounding_box
  @inside_bounding_box
end

#inside_polygonObject

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](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`.



51
52
53
# File 'lib/algolia/models/composition/params.rb', line 51

def inside_polygon
  @inside_polygon
end

#minimum_around_radiusObject

Minimum radius (in meters) for a search around a location when ‘aroundRadius` isn’t set.



46
47
48
# File 'lib/algolia/models/composition/params.rb', line 46

def minimum_around_radius
  @minimum_around_radius
end

#natural_languagesObject

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`.



57
58
59
# File 'lib/algolia/models/composition/params.rb', line 57

def natural_languages
  @natural_languages
end

#numeric_filtersObject

Returns the value of attribute numeric_filters.



30
31
32
# File 'lib/algolia/models/composition/params.rb', line 30

def numeric_filters
  @numeric_filters
end

#optional_filtersObject

Returns the value of attribute optional_filters.



28
29
30
# File 'lib/algolia/models/composition/params.rb', line 28

def optional_filters
  @optional_filters
end

#pageObject

Page of search results to retrieve.



18
19
20
# File 'lib/algolia/models/composition/params.rb', line 18

def page
  @page
end

#queryObject

Search query.



12
13
14
# File 'lib/algolia/models/composition/params.rb', line 12

def query
  @query
end

#query_languagesObject

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](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](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](www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/).



54
55
56
# File 'lib/algolia/models/composition/params.rb', line 54

def query_languages
  @query_languages
end

#relevancy_strictnessObject

Relevancy threshold below which less relevant results aren’t included in the results You can only set ‘relevancyStrictness` on [virtual replica indices](www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/#what-are-virtual-replicas). Use this setting to strike a balance between the relevance and number of returned results.



24
25
26
# File 'lib/algolia/models/composition/params.rb', line 24

def relevancy_strictness
  @relevancy_strictness
end

#rule_contextsObject

Assigns a rule context to the run query [Rule contexts](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.



63
64
65
# File 'lib/algolia/models/composition/params.rb', line 63

def rule_contexts
  @rule_contexts
end

#user_tokenObject

Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](www.algolia.com/doc/guides/sending-events/concepts/usertoken/).



66
67
68
# File 'lib/algolia/models/composition/params.rb', line 66

def user_token
  @user_token
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/algolia/models/composition/params.rb', line 406

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end

  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
    # model
  else
    # models (e.g. Pet) or oneOf
    klass = Algolia::Composition.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
      .build_from_hash(value)
  end
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/algolia/models/composition/params.rb', line 87

def self.attribute_map
  {
    :query => :query,
    :filters => :filters,
    :page => :page,
    :get_ranking_info => :getRankingInfo,
    :relevancy_strictness => :relevancyStrictness,
    :facet_filters => :facetFilters,
    :optional_filters => :optionalFilters,
    :numeric_filters => :numericFilters,
    :hits_per_page => :hitsPerPage,
    :around_lat_lng => :aroundLatLng,
    :around_lat_lng_via_ip => :aroundLatLngViaIP,
    :around_radius => :aroundRadius,
    :around_precision => :aroundPrecision,
    :minimum_around_radius => :minimumAroundRadius,
    :inside_bounding_box => :insideBoundingBox,
    :inside_polygon => :insidePolygon,
    :query_languages => :queryLanguages,
    :natural_languages => :naturalLanguages,
    :enable_rules => :enableRules,
    :rule_contexts => :ruleContexts,
    :user_token => :userToken,
    :click_analytics => :clickAnalytics,
    :analytics => :analytics,
    :analytics_tags => :analyticsTags,
    :enable_ab_test => :enableABTest,
    :enable_re_ranking => :enableReRanking,
    :injected_items => :injectedItems
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/algolia/models/composition/params.rb', line 379

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  types_mapping.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash[key.to_sym] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
          _deserialize(::Regexp.last_match(1), v)
        }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
    end
  end

  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



153
154
155
156
157
158
159
# File 'lib/algolia/models/composition/params.rb', line 153

def self.openapi_nullable
  Set.new(
    [
      :inside_bounding_box
    ]
  )
end

.types_mappingObject

Attribute type mapping.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/algolia/models/composition/params.rb', line 120

def self.types_mapping
  {
    :query => :"String",
    :filters => :"String",
    :page => :"Integer",
    :get_ranking_info => :"Boolean",
    :relevancy_strictness => :"Integer",
    :facet_filters => :"FacetFilters",
    :optional_filters => :"OptionalFilters",
    :numeric_filters => :"NumericFilters",
    :hits_per_page => :"Integer",
    :around_lat_lng => :"String",
    :around_lat_lng_via_ip => :"Boolean",
    :around_radius => :"AroundRadius",
    :around_precision => :"AroundPrecision",
    :minimum_around_radius => :"Integer",
    :inside_bounding_box => :"InsideBoundingBox",
    :inside_polygon => :"Array<Array<Float>>",
    :query_languages => :"Array<SupportedLanguage>",
    :natural_languages => :"Array<SupportedLanguage>",
    :enable_rules => :"Boolean",
    :rule_contexts => :"Array<String>",
    :user_token => :"String",
    :click_analytics => :"Boolean",
    :analytics => :"Boolean",
    :analytics_tags => :"Array<String>",
    :enable_ab_test => :"Boolean",
    :enable_re_ranking => :"Boolean",
    :injected_items => :"Hash<String, ExternalInjectedItem>"
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/algolia/models/composition/params.rb', line 304

def ==(other)
  return true if self.equal?(other)
  self.class == other.class &&
    query == other.query &&
    filters == other.filters &&
    page == other.page &&
    get_ranking_info == other.get_ranking_info &&
    relevancy_strictness == other.relevancy_strictness &&
    facet_filters == other.facet_filters &&
    optional_filters == other.optional_filters &&
    numeric_filters == other.numeric_filters &&
    hits_per_page == other.hits_per_page &&
    around_lat_lng == other.around_lat_lng &&
    around_lat_lng_via_ip == other.around_lat_lng_via_ip &&
    around_radius == other.around_radius &&
    around_precision == other.around_precision &&
    minimum_around_radius == other.minimum_around_radius &&
    inside_bounding_box == other.inside_bounding_box &&
    inside_polygon == other.inside_polygon &&
    query_languages == other.query_languages &&
    natural_languages == other.natural_languages &&
    enable_rules == other.enable_rules &&
    rule_contexts == other.rule_contexts &&
    user_token == other.user_token &&
    click_analytics == other.click_analytics &&
    analytics == other.analytics &&
    analytics_tags == other.analytics_tags &&
    enable_ab_test == other.enable_ab_test &&
    enable_re_ranking == other.enable_re_ranking &&
    injected_items == other.injected_items
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/algolia/models/composition/params.rb', line 485

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to?(:to_hash)
    value.to_hash
  else
    value
  end
end

#eql?(other) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


338
339
340
# File 'lib/algolia/models/composition/params.rb', line 338

def eql?(other)
  self == other
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'lib/algolia/models/composition/params.rb', line 344

def hash
  [
    query,
    filters,
    page,
    get_ranking_info,
    relevancy_strictness,
    facet_filters,
    optional_filters,
    numeric_filters,
    hits_per_page,
    around_lat_lng,
    around_lat_lng_via_ip,
    around_radius,
    around_precision,
    minimum_around_radius,
    inside_bounding_box,
    inside_polygon,
    query_languages,
    natural_languages,
    enable_rules,
    rule_contexts,
    user_token,
    click_analytics,
    analytics,
    analytics_tags,
    enable_ab_test,
    enable_re_ranking,
    injected_items
  ].hash
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



456
457
458
# File 'lib/algolia/models/composition/params.rb', line 456

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/algolia/models/composition/params.rb', line 466

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end

  hash
end

#to_json(*_args) ⇒ Object



460
461
462
# File 'lib/algolia/models/composition/params.rb', line 460

def to_json(*_args)
  to_hash.to_json
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



450
451
452
# File 'lib/algolia/models/composition/params.rb', line 450

def to_s
  to_hash.to_s
end