Indexed 'text' (not string) column not used when searching,


#1

Hi all,

I’ve included a mysql ‘text’ column in my index, and aaf/Ferret
doesn’t use it when I search, UNLESS I specify it as a restrictor, and
then it only searches in that field!

For example:

=> 0 results are returned by a standard (all fields ?) search

Entity.find_by_contents “zixi”
Query: zixi
total hits: 0, results delivered: 0

BUT if I search only in 1 field, I find something

Entity.find_by_contents “extra:zixi”
Entity Load (0.001286) SELECT * FROM entities WHERE
(entities.id in (‘1723’)) AND ( (entities.type = ‘Person’ ) )
Query: extra:zixi
total hits: 1, results delivered: 1
=> #<ActsAsFerret::SearchResults:0x24cd8b0 @total_hits=1,

How is that possible?

For info, here is my table schema :

create_table “entities”, :force => true do |t|
t.string “type”
t.text “extra”
t.datetime “created_at”

and my aaf setting :
file: Entity.rb

acts_as_ferret :remote => true,
               :fields => {
      :name         => {:store => :yes, :boost => 1000},
      :last_name    => {:store => :yes, :boost => 100},
      :tags_names   => {:store => :yes, :boost => 30 } ,
      :first_name   => {:store => :yes, :boost => 10 },
      :type         => {:store => :yes},
      :extra        => {:store => :yes},
      :slaves_list  => {:store => :yes, :boost => 10 },
      :masters_list => {:store => :yes, :boost => 10 },
      :function     => {:store => :yes},
      :name_for_sort=> {:index => :untokenized}
}

TIA

Alain


#2

… additionally, I noticed that prefixing the query term with *:
‘solves’ the problem.

So,
Person.find_by_contents “zixi” -> NO RESULT : WRONG

but
Person.find_by_contents “*:zixi” -> 1 RESULT : CORRECT
Person.find_by_contents “extra:zixi” -> 1 RESULT : CORRECT

This hack would get trickier to implement on queries like :
(a OR B) c name:d
so I’d rather do it the right way.

Why does this happen : bug, or feature?

Alain


#3

Hi Alain,

could you please look in your application’s log for a line reading
‘default field list: …’ and see what’s in there?

cheers,
Jens

On Fri, Jun 15, 2007 at 04:30:19PM +0200, Alain R. wrote:

removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ferret-talk


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
removed_email_address@domain.invalid | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa