On 9/5/06, Mufaddal Khumri <[EMAIL PROTECTED]> wrote:
> Mufaddal Khumri wrote:
> > David Balmain wrote:
> >> On 9/5/06, Mufaddal Khumri <[EMAIL PROTECTED]> wrote:
> >>>
> >>> index << {:name => "Lona"}
> >>> index << {:name => "Frank"}
> >>>
> >>> index.optimize
> >>>
> >>> query = Search::TermQuery.new(:name, "Joe")
> >>
> >> Your problem lies here. The AsciiStandardAnalyzer downcases all of the
> >> data as it is entered into the index, so you should be searching for
> >> "joe", not "Joe". Since you are using the Index class you can just do
> >> it like this also;
> >>
> >> index.search_each("name:Joe", {:limit => :all}) do |doc, score|
> >>
> >> In this case the QueryParser will downcase "Joe" for you.
> >>
> >> Cheers,
> >> Dave
> >
> > Thanks.
> >
>
> > I thought the AsciiStandardAnalyzer would be used by the
> > index.search_each(..) call. How do I specify a analyzer
> > (AsciiStandardAnalyzer) while searching the index? I thought that I
> > could specify the analyzer via the constructor for the Index class.
> > Later when I index data or search the index the set analyzer would be
> > used. Am I understanding this right?
>
> Just read David's post carefully :)
>
> I guess the QueryParser uses the analyzer set:
> index.search_each("name:Joe", {:limit => :all}) do |doc, ....
>
> My next question is how do I get the analyzer to be used when i create
> my query and search like this:
>
> query = Search::TermQuery.new(:name, "Joe")
> index.search_each(query, {:limit => :all}) do |doc, score| ....
>
> Thanks.
I'm not sure why you'd want to do this when you can just pass the
query string to the search_each method and it does it for you. What
exactly are you trying to do? Can't you just do this;
query = Search::TermQuery.new(:name, "Joe".downcase)
Anything more complicated than this and you are better off leaving it
to the QueryParser.
Cheers,
Dave
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk