On 9/2/06, Raul Murciano <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> I have a model with indexed fields (F1, F2, F3...).
>
> I have a field-based search (+F1:..., +F2:...), and a global search
> (which queries all fields with the given terms). Both of them works ok,
> but I would like to exclude a term from the global search (though it
> should remain indexed to support the field-based search), is it
> possible?
Hi Raul,
You probably want to do something like this;
require 'rubygems'
require 'ferret'
i = Ferret::I.new(:default_field => [:f1, :f2, :f3])
i << {:f1 => "hello"}
i << {:f2 => "hello"}
i << {:f3 => "hello"}
i << {:f4 => "hello"}
puts "global"
i.search_each("hello") {|d, s| puts "#{d}"}
puts "field"
i.search_each("f4:hello") {|d, s| puts "#{d}"}
This should print this out;
global
0
1
2
field
3
This should be pretty simple to do through acts_as_ferret too.
Cheers,
Dave
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk