Changeset 158
- Timestamp:
- 02/10/07 08:16:52 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plugin/acts_as_ferret/lib/instance_methods.rb
r156 r158 80 80 logger.debug "ferret_destroy: #{self.class.name} : #{self.id}" 81 81 begin 82 self.class.aaf_index.remove self 82 self.class.aaf_index.remove self.id, self.class.name 83 83 rescue 84 84 logger.warn("Could not find indexed value for this object: #{$!}\n#{$!.backtrace}") trunk/plugin/acts_as_ferret/lib/local_index.rb
r156 r158 75 75 result = [] 76 76 index = ferret_index 77 #logger.debug "query: #{ferret_index.process_query query}"77 logger.debug "query: #{ferret_index.process_query query}" 78 78 total_hits = index.search_each(query, options) do |hit, score| 79 79 doc = index[hit] trunk/plugin/acts_as_ferret/lib/shared_index_class_methods.rb
r155 r158 3 3 module SharedIndexClassMethods 4 4 5 # override the standard find_by_contents for searching a shared index 6 # 7 # please note that records from different models will be fetched in 8 # separate sql calls, so any sql order_by clause given with 9 # find_options[:order] will get ignored. 10 # 11 # TODO: slow on large result sets - fetches result set objects one-by-one 12 def find_by_contents(q, options = {}, find_options = {}) 13 if order = find_options.delete(:order) 14 logger.warn "dropping unused order_by clause #{order}" 15 end 16 id_arrays = {} 17 5 def find_id_by_contents(q, options = {}) 6 # add class name scoping to query if necessary 18 7 unless options[:models] == :all # search needs to be restricted by one or more class names 19 8 options[:models] ||= [] … … 37 26 end 38 27 options.delete :models 28 29 super(q, options) 30 end 39 31 32 # Overrides the standard find_by_contents for searching a shared index. 33 # 34 # please note that records from different models will be fetched in 35 # separate sql calls, so any sql order_by clause given with 36 # find_options[:order] will be ignored. 37 def find_by_contents(q, options = {}, find_options = {}) 38 if order = find_options.delete(:order) 39 logger.warn "dropping unused order_by clause #{order}" 40 end 40 41 total_hits, id_arrays = collect_results(q, options) 41 42 result = retrieve_records(id_arrays, find_options) 42 43 43 # sort so results have the same order they had when originally retrieved 44 44 # from ferret … … 52 52 # get object ids for index hits 53 53 rank = 0 54 total_hits = aaf_index.find_id_by_contents(q, options) do |model, id, score|54 total_hits = find_id_by_contents(q, options) do |model, id, score| 55 55 id_arrays[model] ||= {} 56 56 # store result rank and score
