Search sold edition,rake sunspot:solr:run. NewsBulletin.solr_search,NewsBulletin.solr_reindex. Not working
This commit is contained in:
1 parent
8dd1ab32c1
commit
cb17fe0825
46 files changed
+2597
-263
No files matched your search
@@ -0,0 +1,28 @@
|
||||
module OrbitBasis
|
||||
module BaseModel
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# included do
|
||||
# scope :recent, desc(:_id)
|
||||
# scope :exclude_ids, Proc.new { |ids| where(:_id.nin => ids.map(&:to_i)) }
|
||||
# scope :by_week, where(:created_at.gte => 7.days.ago.utc)
|
||||
# end
|
||||
|
||||
module ClassMethods
|
||||
|
||||
def find_in_batches(opts = {})
|
||||
batch_size = opts[:batch_size] || 1000
|
||||
start = opts.delete(:start).to_i || 0
|
||||
objects = self.limit(batch_size).skip(start)
|
||||
t = Time.new
|
||||
while objects.any?
|
||||
yield objects
|
||||
start += batch_size
|
||||
# Rails.logger.debug("processed #{start} records in #{Time.new - t} seconds") if Rails.logger.debug?
|
||||
break if objects.size < batch_size
|
||||
objects = self.limit(batch_size).skip(start)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,46 @@
|
||||
# coding: utf-8
|
||||
# this is from : https://github.com/jugyo/sunspot_mongoid
|
||||
# this file is special for mongoid_auto_increment_id
|
||||
require 'sunspot'
|
||||
require 'mongoid'
|
||||
require 'sunspot/rails'
|
||||
|
||||
# == Examples:
|
||||
#
|
||||
# class Post
|
||||
# include Mongoid::Document
|
||||
# field :title
|
||||
#
|
||||
# include Sunspot::Mongoid
|
||||
# searchable do
|
||||
# text :title
|
||||
# end
|
||||
# end
|
||||
#
|
||||
module OrbitSearchLib
|
||||
module ObjectSearchable
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
extend Sunspot::Rails::Searchable::ActsAsMethods
|
||||
Sunspot::Adapters::DataAccessor.register(DataAccessor, base)
|
||||
Sunspot::Adapters::InstanceAdapter.register(InstanceAdapter, base)
|
||||
end
|
||||
end
|
||||
|
||||
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter
|
||||
def id
|
||||
@instance.id
|
||||
end
|
||||
end
|
||||
|
||||
class DataAccessor < Sunspot::Adapters::DataAccessor
|
||||
def load(id)
|
||||
@clazz.where(:_id => id).first
|
||||
end
|
||||
|
||||
def load_all(ids)
|
||||
@clazz.where(:_id.in => ids.collect { |id| id.to_i })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -171,7 +171,7 @@ module ParserCommon
|
||||
if (content["main"] == "true" && !page.module_app.nil?)
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
||||
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
|
||||
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}"
|
||||
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}&search_query=#{params[:search_query]}"
|
||||
ret << "'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||
|
||||
Reference in new issue
Block a user