Sha256: e054913b3ce5f376f8f94cdcb8dc85847e8b1e51a4ad1468e97891d2869847d2
Contents?: true
Size: 1.58 KB
Versions: 8
Compression:
Stored size: 1.58 KB
Contents
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, lenient: true, } args[:type] = type if type args.merge options end def execute ActiveSupport::Notifications.instrument "search.elasticsearch", name: "#{self.class.name}#execute", search: to_client_args do Gummi::DbLayer::Document::Search::Result.new client.search(to_client_args), document_class, per_page, page end rescue Faraday::Error::ConnectionFailed Gummi::DbLayer::Document::Search::Result.new nil, document_class, per_page, page end private def size per_page end def from per_page * (page - 1) end def client Gummi.client end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems