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

Changeset 120

Show
Ignore:
Timestamp:
12/19/06 21:54:21 (2 years ago)
Author:
jk
Message:

r2825@monsoon: jk | 2006-12-19 22:54:09 +0100
work arount the annoying stop words-with tokenized-fields-problem - query terms not scoped to a specific field will not be queried against untokenized fields any more

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/demo/test/unit/comment_test.rb

    r111 r120  
    160160  end 
    161161 
    162   # fails due to Ferret bug in 0.10.13, http://pastie.caboo.se/22886 
    163162  def test_stopwords 
    164163    comment = Comment.create( :author => 'john doe', :content => 'Move or shake' ) 
  • trunk/plugin/acts_as_ferret/lib/class_methods.rb

    r119 r120  
    9393          ferret_configuration = { 
    9494            :or_default => false,  
    95             :handle_parse_errors => true 
     95            :handle_parse_errors => true, 
     96            :default_field => '*' 
    9697            #:max_clauses => 512, 
    97             #:default_field => '*', 
    9898            #:analyzer => Ferret::Analysis::StandardAnalyzer.new, 
    9999            # :wild_card_downcase => true 
     
    142142            EOV 
    143143          FerretMixin::Acts::ARFerret::ensure_directory configuration[:index_dir] 
     144 
     145          # now that all fields have been added, we can initialize the default 
     146          # field list to be used by the query parser. 
     147          # It will include all content fields *not* marked as :untokenized. 
     148          # This fixes the otherwise failing CommentTest#test_stopwords  
     149          ferret_configuration[:default_field] = fields_for_ferret.keys.select do |f|  
     150            fields_for_ferret[f][:index] != :untokenized 
     151          end 
     152          logger.debug "set default field list to #{ferret_configuration[:default_field].inspect}" 
    144153        end 
    145154         
     
    399408          result = [] 
    400409          index = self.ferret_index 
     410          # puts "query: #{index.process_query q}" 
    401411          total_hits = index.search_each(q, options) do |hit, score| 
    402412            # only collect result data if we intend to return it 

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