module Gummi module DbLayer module Document module Search module Searching extend ActiveSupport::Concern included do include Virtus.model attribute :document_class, Class attribute :index, String, default: lambda { |search, attr| Gummi::DbLayer::DefaultIndex.name } attribute :type, String attribute :page, Gummi::DbLayer::Fields::PositiveInteger, default: 1 attribute :per_page, Gummi::DbLayer::Fields::PositiveInteger, default: 300 attribute :options, Hash, default: {} end def to_client_args args = { index: index, from: from, size: size, } args[:type] = type if type args.merge options end def execute Gummi::DbLayer::Document::Search::Result.new client.search(to_client_args), document_class, per_page, page end private def size per_page end def from per_page * (page - 1) end def client Gummi::API.client end end end end end end