You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Norbert Pabiś <np...@e-point.pl> on 2002/09/16 14:17:49 UTC

Default conjuction behaviour

Hi,

Now conjuction behaviour in lucene is always set to OR.
In my work I need to set it during runtime.
It is easy with my patched QueryParser.

Please have a look at the patch and say what you think of it.
Maybe it is a good idea to include such a funcionality into Lucene?

-- 
Norbert Pabiś

Re: Default conjuction behaviour

Posted by Norbert Pabiś <np...@e-point.pl>.
Otis Gospodnetic wrote:
> Look for setDefaultOperator
> 
Right. That's what I meant.
I was just confused that it is now renamed to "operator" from 
"conjuction behaviour" as it was named in release 1.2

-- 
Norbert Pabiś


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Default conjuction behaviour

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Look for setDefaultOperator

Otis

--- Norbert_Pabi� <np...@e-point.pl> wrote:
> Otis Gospodnetic wrote:
> > Hello,
> > 
> > This functionality should already be in the QueryParser that is in
> CVS.
> > I'm not sure if the QueryParser in CVS checks the operators as much
> as
> > yours does...
> 
> Well, I have just checked out lucene from CVS and as far as I can see
> 
> you can set default field for query but you cannot set default 
> conjuction behaviour.
> 
> -- 
> Norbert Pabi�
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Default conjuction behaviour

Posted by Norbert Pabiś <np...@e-point.pl>.
Otis Gospodnetic wrote:
> Hello,
> 
> This functionality should already be in the QueryParser that is in CVS.
> I'm not sure if the QueryParser in CVS checks the operators as much as
> yours does...

Well, I have just checked out lucene from CVS and as far as I can see 
you can set default field for query but you cannot set default 
conjuction behaviour.

-- 
Norbert Pabiś



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Default conjuction behaviour

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Hello,

This functionality should already be in the QueryParser that is in CVS.
I'm not sure if the QueryParser in CVS checks the operators as much as
yours does...

Otis



--- Norbert_Pabi� <np...@e-point.pl> wrote:
> Hi,
> 
> Now conjuction behaviour in lucene is always set to OR.
> In my work I need to set it during runtime.
> It is easy with my patched QueryParser.
> 
> Please have a look at the patch and say what you think of it.
> Maybe it is a good idea to include such a funcionality into Lucene?
> 
> -- 
> Norbert Pabi�
> > --- /tmp/uu/QueryParser.jj	Sun Jun  9 22:47:55 2002
> +++ ./QueryParser.jj	Mon Sep 16 14:09:36 2002
> @@ -106,6 +106,10 @@
>   */
>  
>  public class QueryParser {
> +
> +  /** Default conjunction behaviour. */
> +  private int conjunctionBehaviour = CONJ_OR;
> +
>    /** Parses a query string, returning a {@link
> org.apache.lucene.search.Query}.
>     *  @param query	the query string to be parsed.
>     *  @param field	the default field for query terms.
> @@ -122,7 +126,38 @@
>        throw new ParseException(tme.getMessage());
>      }
>    }
> -       
> +
> +  /** Parses a query string, returning a {@link
> org.apache.lucene.search.Query}.
> +   * Enables setting default conjunction behaviour set.
> +   * @param query	the query string to be parsed.
> +   * @param field	the default field for query terms.
> +   * @param analyzer   used to find terms in the query text.
> +   * @param conjunctionBehaviour default conjunction behaviour 
> +   * (NONE, OR, AND)
> +   *  @throws ParseException if the parsing fails
> +   */       
> +  public static Query parse(String query, String field, Analyzer
> analyzer, int conjunctionBehaviour)
> +        throws ParseException, IllegalArgumentException {
> +    if (conjunctionBehaviour != CONJ_NONE && 
> +        conjunctionBehaviour != CONJ_AND && 
> +        conjunctionBehaviour != CONJ_OR) {
> +        throw new IllegalArgumentException("Illegal conjunction
> behaviour:" + conjunctionBehaviour);
> +    } else {
> +        QueryParser queryparser = new QueryParser(field, analyzer);
> +        queryparser.setConjuctionBehaviour(conjunctionBehaviour);
> +
> +        return queryparser.parse(query);
> +    }
> +  }
> +
> +  /** Sets default conjunction behaviour.
> +   * @param conjunctionBehaviour default conjunction behaviour 
> +   * (NONE, OR, AND)
> +   */       
> +  public void setConjuctionBehaviour(int conjunctionBehaviour) {
> +    this.conjunctionBehaviour = conjunctionBehaviour;
> +  }
> +
>    Analyzer analyzer;
>    String field;
>    int phraseSlop = 0;
> @@ -256,9 +291,9 @@
>      System.out.println(q.toString("field"));
>    }
>  
> -  private static final int CONJ_NONE   = 0;
> -  private static final int CONJ_AND    = 1;
> -  private static final int CONJ_OR     = 2;
> +  public static final int CONJ_NONE   = 0;
> +  public static final int CONJ_AND    = 1;
> +  public static final int CONJ_OR     = 2;
>  
>    private static final int MOD_NONE    = 0;
>    private static final int MOD_NOT     = 10;
> @@ -315,7 +350,7 @@
>  // *   Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
>  
>  int Conjunction() : { 
> -  int ret = CONJ_NONE;
> +  int ret = conjunctionBehaviour;
>  }
>  {
>    [ 
> 
> > --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>