Lucene 1.4.3 QueryParser cannot parse "great!" ?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Lucene 1.4.3 QueryParser cannot parse "great!" ?

Zhang, Lisheng
Hi,

We are using lucene 1.4.3, we indexed a string

Company picnic is great!

by IndexWriter created with StandardAnalyzer, into
a field called "all". I also confirmed StandardAnalyzer
processed my input string as tokens:

company
picnic
great

as I expected.

But when I try to create Query by QueryParser

Query q = QueryParser.parse("great!", "all", new StandardAnalyzer());

I got the ParseException:

##########################
Encountered "<EOF>" at line 1, column 7.
Was expecting one of:
    "(" ...
    <QUOTED> ...
    <TERM> ...
    <PREFIXTERM> ...
    <WILDTERM> ...
    "[" ...
    "{" ...
    <NUMBER> ...
#########################

Surely if I use "great" or some other special symbols
at the end like "great-" or "great+", QueryParser is OK.

I would expect QueryParser can process "great!" to take
away "!" so this query is the same as "great"? Is this behavior
expected or is a bug?

Thanks very much for helps,

Lisheng Zhang, Software engineer
   

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lucene 1.4.3 QueryParser cannot parse "great!" ?

Richard Krenek
Here is a list of special characters that must be excaped in a query.

+ - && || ! ( ) { } [ ] ^ " ~ * ? : \

Query q = QueryParser.parse("great\!", "all", new StandardAnalyzer());



On 6/9/05, Zhang, Lisheng <[hidden email]> wrote:

> Hi,
>
> We are using lucene 1.4.3, we indexed a string
>
> Company picnic is great!
>
> by IndexWriter created with StandardAnalyzer, into
> a field called "all". I also confirmed StandardAnalyzer
> processed my input string as tokens:
>
> company
> picnic
> great
>
> as I expected.
>
> But when I try to create Query by QueryParser
>
> Query q = QueryParser.parse("great!", "all", new StandardAnalyzer());
>
> I got the ParseException:
>
> ##########################
> Encountered "<EOF>" at line 1, column 7.
> Was expecting one of:
>     "(" ...
>     <QUOTED> ...
>     <TERM> ...
>     <PREFIXTERM> ...
>     <WILDTERM> ...
>     "[" ...
>     "{" ...
>     <NUMBER> ...
> #########################
>
> Surely if I use "great" or some other special symbols
> at the end like "great-" or "great+", QueryParser is OK.
>
> I would expect QueryParser can process "great!" to take
> away "!" so this query is the same as "great"? Is this behavior
> expected or is a bug?
>
> Thanks very much for helps,
>
> Lisheng Zhang, Software engineer
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Lucene 1.4.3 QueryParser cannot parse "great!" ?

Zhang, Lisheng
Hi Richard,

Thanks very much! That works.

Lisheng

-----Original Message-----
From: Richard Krenek [mailto:[hidden email]]
Sent: Thursday, June 09, 2005 3:18 PM
To: [hidden email]
Subject: Re: Lucene 1.4.3 QueryParser cannot parse "great!" ?


Here is a list of special characters that must be excaped in a query.

+ - && || ! ( ) { } [ ] ^ " ~ * ? : \

Query q = QueryParser.parse("great\!", "all", new StandardAnalyzer());



On 6/9/05, Zhang, Lisheng <[hidden email]> wrote:

> Hi,
>
> We are using lucene 1.4.3, we indexed a string
>
> Company picnic is great!
>
> by IndexWriter created with StandardAnalyzer, into
> a field called "all". I also confirmed StandardAnalyzer
> processed my input string as tokens:
>
> company
> picnic
> great
>
> as I expected.
>
> But when I try to create Query by QueryParser
>
> Query q = QueryParser.parse("great!", "all", new StandardAnalyzer());
>
> I got the ParseException:
>
> ##########################
> Encountered "<EOF>" at line 1, column 7.
> Was expecting one of:
>     "(" ...
>     <QUOTED> ...
>     <TERM> ...
>     <PREFIXTERM> ...
>     <WILDTERM> ...
>     "[" ...
>     "{" ...
>     <NUMBER> ...
> #########################
>
> Surely if I use "great" or some other special symbols
> at the end like "great-" or "great+", QueryParser is OK.
>
> I would expect QueryParser can process "great!" to take
> away "!" so this query is the same as "great"? Is this behavior
> expected or is a bug?
>
> Thanks very much for helps,
>
> Lisheng Zhang, Software engineer
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lucene 1.4.3 QueryParser cannot parse "great!" ?

Chris Lamprecht
See QueryParser.escape(), it automatically escapes these special
characters for you.

On 6/9/05, Zhang, Lisheng <[hidden email]> wrote:

> Hi Richard,
>
> Thanks very much! That works.
>
> Lisheng
>
> -----Original Message-----
> From: Richard Krenek [mailto:[hidden email]]
> Sent: Thursday, June 09, 2005 3:18 PM
> To: [hidden email]
> Subject: Re: Lucene 1.4.3 QueryParser cannot parse "great!" ?
>
>
> Here is a list of special characters that must be excaped in a query.
>
> + - && || ! ( ) { } [ ] ^ " ~ * ? : \
>
> Query q = QueryParser.parse("great\!", "all", new StandardAnalyzer());
>
>
>
> On 6/9/05, Zhang, Lisheng <[hidden email]> wrote:
> > Hi,
> >
> > We are using lucene 1.4.3, we indexed a string
> >
> > Company picnic is great!
> >
> > by IndexWriter created with StandardAnalyzer, into
> > a field called "all". I also confirmed StandardAnalyzer
> > processed my input string as tokens:
> >
> > company
> > picnic
> > great
> >
> > as I expected.
> >
> > But when I try to create Query by QueryParser
> >
> > Query q = QueryParser.parse("great!", "all", new StandardAnalyzer());
> >
> > I got the ParseException:
> >
> > ##########################
> > Encountered "<EOF>" at line 1, column 7.
> > Was expecting one of:
> >     "(" ...
> >     <QUOTED> ...
> >     <TERM> ...
> >     <PREFIXTERM> ...
> >     <WILDTERM> ...
> >     "[" ...
> >     "{" ...
> >     <NUMBER> ...
> > #########################
> >
> > Surely if I use "great" or some other special symbols
> > at the end like "great-" or "great+", QueryParser is OK.
> >
> > I would expect QueryParser can process "great!" to take
> > away "!" so this query is the same as "great"? Is this behavior
> > expected or is a bug?
> >
> > Thanks very much for helps,
> >
> > Lisheng Zhang, Software engineer
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Lucene 1.4.3 QueryParser cannot parse "great!" ?

Zhang, Lisheng
In reply to this post by Richard Krenek
Hi Chris,

Thanks very much, that also works well!

Lisheng

-----Original Message-----
From: Chris Lamprecht [mailto:[hidden email]]
Sent: Thursday, June 09, 2005 6:03 PM
To: [hidden email]
Subject: Re: Lucene 1.4.3 QueryParser cannot parse "great!" ?


See QueryParser.escape(), it automatically escapes these special
characters for you.

On 6/9/05, Zhang, Lisheng <[hidden email]> wrote:

> Hi Richard,
>
> Thanks very much! That works.
>
> Lisheng
>
> -----Original Message-----
> From: Richard Krenek [mailto:[hidden email]]
> Sent: Thursday, June 09, 2005 3:18 PM
> To: [hidden email]
> Subject: Re: Lucene 1.4.3 QueryParser cannot parse "great!" ?
>
>
> Here is a list of special characters that must be excaped in a query.
>
> + - && || ! ( ) { } [ ] ^ " ~ * ? : \
>
> Query q = QueryParser.parse("great\!", "all", new StandardAnalyzer());
>
>
>
> On 6/9/05, Zhang, Lisheng <[hidden email]> wrote:
> > Hi,
> >
> > We are using lucene 1.4.3, we indexed a string
> >
> > Company picnic is great!
> >
> > by IndexWriter created with StandardAnalyzer, into
> > a field called "all". I also confirmed StandardAnalyzer
> > processed my input string as tokens:
> >
> > company
> > picnic
> > great
> >
> > as I expected.
> >
> > But when I try to create Query by QueryParser
> >
> > Query q = QueryParser.parse("great!", "all", new StandardAnalyzer());
> >
> > I got the ParseException:
> >
> > ##########################
> > Encountered "<EOF>" at line 1, column 7.
> > Was expecting one of:
> >     "(" ...
> >     <QUOTED> ...
> >     <TERM> ...
> >     <PREFIXTERM> ...
> >     <WILDTERM> ...
> >     "[" ...
> >     "{" ...
> >     <NUMBER> ...
> > #########################
> >
> > Surely if I use "great" or some other special symbols
> > at the end like "great-" or "great+", QueryParser is OK.
> >
> > I would expect QueryParser can process "great!" to take
> > away "!" so this query is the same as "great"? Is this behavior
> > expected or is a bug?
> >
> > Thanks very much for helps,
> >
> > Lisheng Zhang, Software engineer
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Lucene 1.4.3 QueryParser cannot parse "great!" ?

Zhang, Lisheng
In reply to this post by Richard Krenek
Hi,

Thanks for the info, that solved my problem, may
I ask one question further: what is the reason
why "!" must be escaped?

I can see why "+ - * ? \ ~ :" must be escaped since
they have some usage in query formulation, is "!"
part of the query syntax?

Best regards, Lisheng


-----Original Message-----
From: Richard Krenek [mailto:[hidden email]]
Sent: Thursday, June 09, 2005 3:18 PM
To: [hidden email]
Subject: Re: Lucene 1.4.3 QueryParser cannot parse "great!" ?


Here is a list of special characters that must be excaped in a query.

+ - && || ! ( ) { } [ ] ^ " ~ * ? : \

Query q = QueryParser.parse("great\!", "all", new StandardAnalyzer());



On 6/9/05, Zhang, Lisheng <[hidden email]> wrote:

> Hi,
>
> We are using lucene 1.4.3, we indexed a string
>
> Company picnic is great!
>
> by IndexWriter created with StandardAnalyzer, into
> a field called "all". I also confirmed StandardAnalyzer
> processed my input string as tokens:
>
> company
> picnic
> great
>
> as I expected.
>
> But when I try to create Query by QueryParser
>
> Query q = QueryParser.parse("great!", "all", new StandardAnalyzer());
>
> I got the ParseException:
>
> ##########################
> Encountered "<EOF>" at line 1, column 7.
> Was expecting one of:
>     "(" ...
>     <QUOTED> ...
>     <TERM> ...
>     <PREFIXTERM> ...
>     <WILDTERM> ...
>     "[" ...
>     "{" ...
>     <NUMBER> ...
> #########################
>
> Surely if I use "great" or some other special symbols
> at the end like "great-" or "great+", QueryParser is OK.
>
> I would expect QueryParser can process "great!" to take
> away "!" so this query is the same as "great"? Is this behavior
> expected or is a bug?
>
> Thanks very much for helps,
>
> Lisheng Zhang, Software engineer
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lucene 1.4.3 QueryParser cannot parse "great!" ?

Chris Lamprecht
! can be used before a term for NOT, similar to - (minus).  


On 6/9/05, Zhang, Lisheng <[hidden email]> wrote:

> Hi,
>
> Thanks for the info, that solved my problem, may
> I ask one question further: what is the reason
> why "!" must be escaped?
>
> I can see why "+ - * ? \ ~ :" must be escaped since
> they have some usage in query formulation, is "!"
> part of the query syntax?
>
> Best regards, Lisheng
>
>
> -----Original Message-----
> From: Richard Krenek [mailto:[hidden email]]
> Sent: Thursday, June 09, 2005 3:18 PM
> To: [hidden email]
> Subject: Re: Lucene 1.4.3 QueryParser cannot parse "great!" ?
>
>
> Here is a list of special characters that must be excaped in a query.
>
> + - && || ! ( ) { } [ ] ^ " ~ * ? : \
>
> Query q = QueryParser.parse("great\!", "all", new StandardAnalyzer());
>
>
>
> On 6/9/05, Zhang, Lisheng <[hidden email]> wrote:
> > Hi,
> >
> > We are using lucene 1.4.3, we indexed a string
> >
> > Company picnic is great!
> >
> > by IndexWriter created with StandardAnalyzer, into
> > a field called "all". I also confirmed StandardAnalyzer
> > processed my input string as tokens:
> >
> > company
> > picnic
> > great
> >
> > as I expected.
> >
> > But when I try to create Query by QueryParser
> >
> > Query q = QueryParser.parse("great!", "all", new StandardAnalyzer());
> >
> > I got the ParseException:
> >
> > ##########################
> > Encountered "<EOF>" at line 1, column 7.
> > Was expecting one of:
> >     "(" ...
> >     <QUOTED> ...
> >     <TERM> ...
> >     <PREFIXTERM> ...
> >     <WILDTERM> ...
> >     "[" ...
> >     "{" ...
> >     <NUMBER> ...
> > #########################
> >
> > Surely if I use "great" or some other special symbols
> > at the end like "great-" or "great+", QueryParser is OK.
> >
> > I would expect QueryParser can process "great!" to take
> > away "!" so this query is the same as "great"? Is this behavior
> > expected or is a bug?
> >
> > Thanks very much for helps,
> >
> > Lisheng Zhang, Software engineer
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]