lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adriano Crestani <adrianocrest...@gmail.com>
Subject Re: Escaping Special Characters
Date Mon, 04 Jul 2011 17:16:12 GMT
Hi Govind,

escape() method should only be used to escape term, not the query itself. If
the user is entering the query, it's his responsibility to escape the query.

On Mon, Jul 4, 2011 at 4:21 AM, govind bhardwaj <govinsb90@gmail.com> wrote:

> Hi,
>
> I am using Lucene version 3.1
> Previously I had trouble regarding special characters as when I entered
> "---" as my input, it gave the following error
>
>
> *Caused by: org.apache.lucene.queryParser.ParseException: Encountered " "-"
> "- "" at line 1, column 1.
> Was expecting one of:
>    "(" ...
>    "*" ...
>    <QUOTED> ...
>    <TERM> ...
>    <PREFIXTERM> ...
>    <WILDTERM> ...
>    "[" ...
>    "{" ...
>    <NUMBER> ...
>    <TERM> ...
>    "*" ...
>
> *To overcome this, I used escape() method of the QueryParser and worked
> fine. But now, unlike previously, the search for "item*" yielded no results
> because I guess it escaped the asterisk character too. How should I go
> about
> preventing this from happening ? I am using MultiFieldQueryParser.
>
>
>
> Govind
> *
>
> *--
> No trees were harmed in the creation of this message, but several thousand
> electrons were mildly inconvenienced.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message