Hey Alain,

finally jumped on board? :-) hope to see you in berlin in a few month ..

> Is this the proper syntax for multi-words queries:
>
>   first_name|last_name:(jo* OR va*)

i would suggest to use the OO-Syntax for more complex queries .. like  
that:

query = BooleanQuery.new
[ :first_name, :last_name ].each do |key|
   query.add_query( PrefixQuery.new( key, 'jo' ), :should )
end


for a people-livesearch, i do something like [1]:

def build_livesearch_query( fields, q )
   q = filter_special_characters( q ) # custom method
   query = BooleanQuery.new
   fields.uniq.each do |field|
     sq = SpanNearQuery.new(:in_order => true, :slop => 1)
     terms = analyze_query(q, field) # custom method
     terms.each do |term|
       sq << SpanPrefixQuery.new( field, term )
     end
     query << sq
   end
   query
end

i call that like

build_livesearch_query( [:first_name, :last_name, :email, q )     # q  
is an array of search words

Ben


[1] all of the code at http://bugs.omdb.org/browser/trunk/lib/omdb/ 
ferret/local_search.rb

_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to