Class: AgnosticBackend::Queryable::Elasticsearch::Executor

Inherits:
AgnosticBackend::Queryable::Executor show all
Includes:
Utilities
Defined in:
lib/agnostic_backend/queryable/elasticsearch/executor.rb

Instance Attribute Summary

Attributes inherited from AgnosticBackend::Queryable::Executor

#options, #query, #visitor

Instance Method Summary collapse

Methods included from Utilities

included

Methods inherited from AgnosticBackend::Queryable::Executor

#initialize

Constructor Details

This class inherits a constructor from AgnosticBackend::Queryable::Executor

Instance Method Details

#executeObject



7
8
9
10
11
12
13
14
# File 'lib/agnostic_backend/queryable/elasticsearch/executor.rb', line 7

def execute
  if scroll_cursor.present?
    response = client.send_request(:post, path: "_search/scroll", body: params)
  else 
    response = client.send_request(:post, path: "#{index.index_name}/#{index.type}/_search", body: params)
  end          
  ResultSet.new(ActiveSupport::JSON.decode(response.body), query)
end

#paramsObject



20
21
22
# File 'lib/agnostic_backend/queryable/elasticsearch/executor.rb', line 20

def params
  scroll_cursor.present? ? scroll_cursor : query.accept(visitor)
end

#to_sObject



16
17
18
# File 'lib/agnostic_backend/queryable/elasticsearch/executor.rb', line 16

def to_s
  params
end