Class: RecombeeApiClient::AddSearchSynonym

Inherits:
ApiRequest
  • Object
show all
Defined in:
lib/recombee_api_client/api/add_search_synonym.rb

Overview

Adds a new synonym for the [Search items](docs.recombee.com/api#search-items).

When the term is used in the search query, the synonym is also used for the full-text search. Unless ‘oneWay=true`, it works also in the opposite way (synonym -> term).

An example of a synonym can be ‘science fiction` for the term sci-fi.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashNormalizer

#camelize, #normalize_hash_to_camel_case

Constructor Details

#initialize(term, synonym, optional = {}) ⇒ AddSearchSynonym

  • *Required arguments*

    • term -> A word to which the synonym is specified.

    • synonym -> A word that should be considered equal to the term by the full-text search engine.

  • *Optional arguments (given as hash optional)*

    • oneWay -> If set to true, only term -> synonym is considered. If set to false, also synonym -> term works.

Default: false.



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 32

def initialize(term, synonym, optional = {})
  @term = term
  @synonym = synonym
  optional = normalize_hash_to_camel_case(optional)
  @one_way = optional['oneWay']
  @optional = optional
  @timeout = 10_000
  @ensure_https = false
  @optional.each do |par, _|
    raise UnknownOptionalParameter.new(par) unless ['oneWay'].include? par
  end
end

Instance Attribute Details

#ensure_httpsObject

Returns the value of attribute ensure_https.



19
20
21
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 19

def ensure_https
  @ensure_https
end

#one_wayObject (readonly)

Returns the value of attribute one_way.



18
19
20
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 18

def one_way
  @one_way
end

#synonymObject (readonly)

Returns the value of attribute synonym.



18
19
20
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 18

def synonym
  @synonym
end

#termObject (readonly)

Returns the value of attribute term.



18
19
20
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 18

def term
  @term
end

#timeoutObject

Returns the value of attribute timeout.



19
20
21
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 19

def timeout
  @timeout
end

Instance Method Details

#body_parametersObject

Values of body parameters as a Hash



51
52
53
54
55
56
57
58
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 51

def body_parameters
  p = {}
  p['term'] = @term
  p['synonym'] = @synonym
  p['oneWay'] = @optional['oneWay'] if @optional.include? 'oneWay'

  p
end

#methodObject

HTTP method



46
47
48
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 46

def method
  :post
end

#pathObject

Relative path to the endpoint



67
68
69
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 67

def path
  '/{databaseId}/synonyms/items/'
end

#query_parametersObject

Values of query parameters as a Hash. name of parameter => value of the parameter



62
63
64
# File 'lib/recombee_api_client/api/add_search_synonym.rb', line 62

def query_parameters
  {}
end