Sha256: d0f447881dc262f5dbac07f1a0e5e1fd88fcdedce4855214d94d656a9a6b50c8
Contents?: true
Size: 1.5 KB
Versions: 3
Compression:
Stored size: 1.5 KB
Contents
require 'active_support/concern' module Georgia module Indexer class TireAdapter module GeorgiaPageExtension extend ActiveSupport::Concern included do include ::Tire::Model::Search include ::Tire::Model::Callbacks def to_indexed_json keywords = current_revision.present? ? current_revision.contents.map(&:keyword_list).flatten.uniq.join(', ') : "" tags = tag_list.join(', ') class_name = self.class.name indexed_hash = { title: title, text: text, excerpt: excerpt, keywords: keywords, url: url, template: template, tags: tags, tag_list: tag_list, publish_state: publish_state, class_name: class_name, updated_at: updated_at.strftime('%F'), revision_id: revision_id } indexed_hash.to_json end def self.search model, params model.tire.search(page: (params[:page] || 1), per_page: (params[:per] || 25)) do if params[:query].present? query do boolean do must { string params[:query], default_operator: "AND" } end end sort { by (params[:o] || :updated_at), (params[:dir] || :desc) } end end.results end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems