lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Boyd <andrew.b...@mindspring.com>
Subject RE: DEFAULT_OPERATOR_AND
Date Thu, 18 Aug 2005 15:28:35 GMT
What about trying something like:

        BooleanQuery booQuery = new BooleanQuery();
        Query titleQuery = null;

            QueryParser.Operator operator = contentParser.getDefaultOperator();

            if(QueryParser.Operator.AND == operator){
                //logger.debug("Content Operator is AND");
                booQuery.add(contentParser.parse(searchStr), BooleanClause.Occur.MUST);
            } else{
                //logger.debug("Content Operator is OR");
                booQuery.add(contentParser.parse(searchStr), BooleanClause.Occur.SHOULD);
            }

            titleQuery = titleParser.parse(searchStr);

            titleQuery.setBoost(Document.TITLE_BOOST);
            booQuery.add(titleQuery, BooleanClause.Occur.SHOULD);

Instead of using MultiFieldQueryParser just use multiple QueryParsers and knit them together
with a BooleanQuery.

Andrew

-----Original Message-----
From: Karthik N S <karthik@controlnet.co.in>
Sent: Aug 18, 2005 12:48 AM
To: java-user@lucene.apache.org
Subject: RE: DEFAULT_OPERATOR_AND

Hi Luceners..

Apologies...........


Does this mean MultiFieldQueryParser will always have to use
'DEFAULT_OPERATOR_OR' instead of DEFAULT_OPERATOR_AND
operations.

  Is there any alternative in handling this processs ( other then API
'replaceAll(" ", " AND ")' substution)


Please enlighten me



With regards
Karthik


-----Original Message-----
From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
Sent: Thursday, August 18, 2005 7:09 AM
To: java-user@lucene.apache.org
Subject: Re: DEFAULT_OPERATOR_AND



On Aug 17, 2005, at 2:45 AM, Karthik N S wrote:
> Hi  Lucener's
>
> Apologies..........
>
> I have seen forms using  'DEFAULT_OPERATOR_AND'  with  something
> like below
>
>  > QueryParser parser = new QueryParser( "terms", analyzer);
>  > parser.setOperator(QueryParser.DEFAULT_OPERATOR_AND);
>  > query = parser.parse(TextParameters);
>
> How to use the DEFAULT_OPERATOR_AND  when using
> MultiFieldQueryParser  as below
>
> "query = MultiFieldQueryParser.parse("text",fields,analyzer);" ?
>
> [ I also searched the other Form's for same but no answers.]

MultiFieldQueryParser does not adhere to the default operator
setting, and will always use OR.

     Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message