From java-user-return-50240-apmail-lucene-java-user-archive=lucene.apache.org@lucene.apache.org Mon Jul 4 17:17:04 2011 Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9A64A663C for ; Mon, 4 Jul 2011 17:17:04 +0000 (UTC) Received: (qmail 18858 invoked by uid 500); 4 Jul 2011 17:17:02 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 18745 invoked by uid 500); 4 Jul 2011 17:17:01 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 18737 invoked by uid 99); 4 Jul 2011 17:17:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jul 2011 17:17:01 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of adrianocrestani@gmail.com designates 209.85.210.48 as permitted sender) Received: from [209.85.210.48] (HELO mail-pz0-f48.google.com) (209.85.210.48) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jul 2011 17:16:53 +0000 Received: by pzk10 with SMTP id 10so1203156pzk.35 for ; Mon, 04 Jul 2011 10:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=HLdwf0ZSfJb/X7r5c+l6xMd846MLPw4tItalYjJgQr4=; b=RJrZs6j89kYX+XMmEZlw86gFY1zRzNLx8r7g71zkJsiYfdGN3pdUySLt/7p5VS/FcL zra3IqRDFIhVFuLfy1V5L++lGl5v5rcZu254RJLyDqV13OMQYiNSDYfydat/Joz1sSfu SGkubapQTYq6SEFrFHLbXsodMKucSrQsu+0No= Received: by 10.68.37.68 with SMTP id w4mr7780362pbj.179.1309799792098; Mon, 04 Jul 2011 10:16:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.59.9 with HTTP; Mon, 4 Jul 2011 10:16:12 -0700 (PDT) In-Reply-To: References: From: Adriano Crestani Date: Mon, 4 Jul 2011 13:16:12 -0400 Message-ID: Subject: Re: Escaping Special Characters To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=bcaec51f93d755bd2f04a741875c X-Virus-Checked: Checked by ClamAV on apache.org --bcaec51f93d755bd2f04a741875c Content-Type: text/plain; charset=ISO-8859-1 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 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: > "(" ... > "*" ... > ... > ... > ... > ... > "[" ... > "{" ... > ... > ... > "*" ... > > *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. > --bcaec51f93d755bd2f04a741875c--