Sha256: f8a5cc69f8e650e8f1b9deb1317c03c6b24da80a114e3517387f136552d06805

Contents?: true

Size: 986 Bytes

Versions: 7

Compression:

Stored size: 986 Bytes

Contents

module AgnosticBackend
  module Queryable
    module Elasticsearch
      class Executor < AgnosticBackend::Queryable::Executor
        include AgnosticBackend::Utilities

        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

        def to_s
          params
        end

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

        private

        def client
          index.client
        end

        def index
          query.context.index
        end

        def scroll_cursor
          scroll_cursor_expression.accept(visitor) if scroll_cursor_expression
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
agnostic_backend-1.0.4 lib/agnostic_backend/queryable/elasticsearch/executor.rb
agnostic_backend-1.0.3 lib/agnostic_backend/queryable/elasticsearch/executor.rb
agnostic_backend-1.0.2 lib/agnostic_backend/queryable/elasticsearch/executor.rb
agnostic_backend-1.0.1 lib/agnostic_backend/queryable/elasticsearch/executor.rb
agnostic_backend-1.0.0 lib/agnostic_backend/queryable/elasticsearch/executor.rb
agnostic_backend-0.9.9 lib/agnostic_backend/queryable/elasticsearch/executor.rb
agnostic_backend-0.9.8 lib/agnostic_backend/queryable/elasticsearch/executor.rb