To edit pages or tickets please login with username/password: aaf/aaf

Changeset 158

Show
Ignore:
Timestamp:
02/10/07 08:16:52 (2 years ago)
Author:
jk
Message:

really fixing #88

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugin/acts_as_ferret/lib/instance_methods.rb

    r156 r158  
    8080      logger.debug "ferret_destroy: #{self.class.name} : #{self.id}" 
    8181      begin 
    82         self.class.aaf_index.remove self 
     82        self.class.aaf_index.remove self.id, self.class.name 
    8383      rescue 
    8484        logger.warn("Could not find indexed value for this object: #{$!}\n#{$!.backtrace}") 
  • trunk/plugin/acts_as_ferret/lib/local_index.rb

    r156 r158  
    7575      result = [] 
    7676      index = ferret_index 
    77       #logger.debug "query: #{ferret_index.process_query query}" 
     77      logger.debug "query: #{ferret_index.process_query query}" 
    7878      total_hits = index.search_each(query, options) do |hit, score| 
    7979        doc = index[hit] 
  • trunk/plugin/acts_as_ferret/lib/shared_index_class_methods.rb

    r155 r158  
    33  module SharedIndexClassMethods 
    44 
    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 
    187      unless options[:models] == :all # search needs to be restricted by one or more class names 
    198        options[:models] ||= []  
     
    3726      end 
    3827      options.delete :models 
     28       
     29      super(q, options) 
     30    end 
    3931 
     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 
    4041      total_hits, id_arrays = collect_results(q, options) 
    4142      result = retrieve_records(id_arrays, find_options) 
    42        
    4343      # sort so results have the same order they had when originally retrieved 
    4444      # from ferret 
     
    5252      # get object ids for index hits 
    5353      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| 
    5555        id_arrays[model] ||= {} 
    5656        # store result rank and score 

To edit pages or tickets please login with username/password: aaf/aaf