Forum: Ferret setting the default operator on a QueryParser

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
roop (Guest)
on 2006-04-12 00:42
Hi all,

Thanks to the authors for the amazing work on Ferret! I have a question
about setting up the standard operators on a QueryParser. I would like
my parser to default to AND queries rather than the default OR.

In Java I would simply do:

QueryParser parser = new QueryParser("contents", new
StandardAnalyzer());
parser.setDefaultOperator(QueryParser.Operator.AND);

But I can't find the corresponding method in the Ferret API. Have I
missed it or is there a workaround?

Thanks,
Roop
Jens K. (Guest)
on 2006-04-12 11:13
(Received via mailing list)
Hi!

On Tue, Apr 11, 2006 at 10:42:35PM +0200, roop wrote:
> parser.setDefaultOperator(QueryParser.Operator.AND);
Afair the option is named :occur_default and takes one of
Ferret::Search::BooleanClause::Occur::MUST or
Ferret::Search::BooleanClause::Occur::SHOULD. You can use this option in
the Ferret::Index::Index constructor (which will internally create a
query parser) or directly when constructing the query parser yourself.

Jens

--
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer 
removed_email_address@domain.invalid
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
roop (Guest)
on 2006-04-12 22:55
Thanks. The difference between setting the AND/OR default operator
versus setting the MUST/SHOULD default occur appears to be redundant
then? In any case, thanks for the tip.
This topic is locked and can not be replied to.