diff --git a/lib/typesense/synonym_set.rb b/lib/typesense/synonym_set.rb index b28cbea..da93395 100644 --- a/lib/typesense/synonym_set.rb +++ b/lib/typesense/synonym_set.rb @@ -7,6 +7,10 @@ def initialize(synonym_set_name, api_call) @api_call = api_call end + def upsert(params) + @api_call.put(endpoint_path, params) + end + def retrieve @api_call.get(endpoint_path) end diff --git a/spec/typesense/synonym_set_spec.rb b/spec/typesense/synonym_set_spec.rb index e4e1efe..751e4c0 100644 --- a/spec/typesense/synonym_set_spec.rb +++ b/spec/typesense/synonym_set_spec.rb @@ -46,6 +46,16 @@ # Ignore errors if already deleted end + describe '#upsert' do + it 'creates a synonym set and returns it' do + skip('SynonymSets is only supported in Typesense v30+') unless typesense_v30_or_above? + + result = synonym_set.upsert(synonym_set_data) + + expect(result['items']).to eq(synonym_set_data['items']) + end + end + describe '#retrieve' do it 'returns the specified synonym set' do skip('SynonymSets is only supported in Typesense v30+') unless typesense_v30_or_above?