Module: Swiftype::Easy::Engine

Included in:
Swiftype::Easy
Defined in:
lib/swiftype/easy.rb

Instance Method Summary collapse

Instance Method Details

#create_engine(engine = {}) ⇒ Object



16
17
18
# File 'lib/swiftype/easy.rb', line 16

def create_engine(engine={})
  post("engines.json", :engine => engine)
end

#destroy_engine(engine_id) ⇒ Object



19
20
21
# File 'lib/swiftype/easy.rb', line 19

def destroy_engine(engine_id)
  delete("engines/#{engine_id}")
end

#enginesObject



12
13
14
15
# File 'lib/swiftype/easy.rb', line 12

def engines
  test_search_module
  get("engines.json")
end

#search(engine_id, query, options = {}) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/swiftype/easy.rb', line 29

def search(engine_id, query, options={})
  search_params = { :q => query }.merge(parse_search_options(options))
  response = post("engines/#{engine_id}/search.json", search_params)
  results = {}
  response['records'].each { |document_type, records| results[document_type] = records.map { |d| Swiftype::Document.new(d) }}
  results
end

#suggest(engine_id, query, options = {}) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/swiftype/easy.rb', line 22

def suggest(engine_id, query, options={})
  search_params = { :q => query }.merge(parse_suggest_options(options))
  response = post("engines/#{engine_id}/suggest.json", search_params)
  results = {}
  response['records'].each { |document_type, records| results[document_type] = records.map { |d| Swiftype::Document.new(d) }}
  results
end