Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 7496 invoked from network); 4 Apr 2006 12:59:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Apr 2006 12:59:50 -0000 Received: (qmail 33700 invoked by uid 500); 4 Apr 2006 12:59:37 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 33621 invoked by uid 500); 4 Apr 2006 12:59:36 -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 33413 invoked by uid 99); 4 Apr 2006 12:59:32 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Apr 2006 05:59:31 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [69.55.225.129] (HELO ehatchersolutions.com) (69.55.225.129) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Apr 2006 05:59:30 -0700 Received: by ehatchersolutions.com (Postfix, from userid 504) id 03FEC33CFDC; Tue, 4 Apr 2006 08:59:08 -0400 (EDT) Received: from [128.143.193.79] (d-128-193-79.bootp.Virginia.EDU [128.143.193.79]) by ehatchersolutions.com (Postfix) with ESMTP id 6A9B033CFEE for ; Tue, 4 Apr 2006 08:59:00 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v749.3) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Erik Hatcher Subject: Re: QueryParser error + solution Date: Tue, 4 Apr 2006 08:58:57 -0400 To: java-user@lucene.apache.org X-Mailer: Apple Mail (2.749.3) X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on javelina X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.0.1 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N If you're going to escape all the special characters used as operators in the query expression, then what is the point of using QueryParser? Seems like you could just tokenize the text yourself and build a Query instance via API to support your needs. Do you need to leverage any special operators of QueryParser? Or are you just using it to take a string of words and turn it into a BooleanQuery? Erik On Apr 4, 2006, at 7:29 AM, miki sun wrote: > Thanks Erik and Michael! > > I copied some code from demo.SearchFiles.java, I do not have a more > clearer tracing message. Now it works. > > But do you have a better way than this: > > //escaping special chars for query parser > for (int i = 0; i < qr.length(); i ++) > { > if( (qr.charAt(i) == '+') ||(qr.charAt(i) == '-') > ||(qr.charAt(i) == '&')||(qr.charAt(i) == '~') > ||(qr.charAt(i) == '|')|| (qr.charAt(i) == '!') > ||(qr.charAt(i) == '[')||(qr.charAt(i) == ']') > ||(qr.charAt(i) == '(')||(qr.charAt(i) == ')') > ||(qr.charAt(i) == '{')||(qr.charAt(i) == '}') > ||(qr.charAt(i) == '^')||(qr.charAt(i) == '"') > ||(qr.charAt(i) == '*')||(qr.charAt(i) == '?') > ||(qr.charAt(i) == ':')||(qr.charAt(i) == '\\') ) > theQueries += "\\" + qr.charAt(i); > else > theQueries += qr.charAt(i) ; > } > > > > ----Original Message Follows---- > From: Erik Hatcher > Reply-To: java-user@lucene.apache.org > To: java-user@lucene.apache.org > Subject: Re: QueryParser error > Date: Tue, 4 Apr 2006 07:01:41 -0400 > > Miki hasn't posted a complete stack trace, and if the NPE is > coming from QueryParser it would likely give stack trace > information pinpointing precisely where the issue is. My hunch is > some other code is obfuscating the real issue. A complete stack > trace would be much more helpful. > > Erik > > > On Apr 4, 2006, at 6:55 AM, Michael Barry wrote: > >> Exclamation point too ... check out the "Escaping Special Characters" >> section in the QueryParser syntax guide (http://lucene.apache.org/ >> java/docs/queryparsersyntax.html) >> >> miki sun wrote: >>> Still got error even without colon: >>> >>> Error in parse query :The light of the body is the eye if >>> therefore thine eye be single, thy whole body shall be full of >>> light. But if thine eye be evil, thy whole body shall be full of >>> darkness. If therefore the light that is in thee be darkness, >>> how great is that darkness! >>> >>> java.lang.NullPointerException >>> >>> >>> >>> ----Original Message Follows---- >>> From: Michael Barry >>> Reply-To: java-user@lucene.apache.org >>> To: java-user@lucene.apache.org >>> Subject: Re: QueryParser error >>> Date: Tue, 04 Apr 2006 06:44:02 -0400 >>> >>> You need to escape the colons. >>> >>> miki sun wrote: >>>> Hi there >>>> >>>> Who can tell me why I got the the queryParser error for the >>>> following query: >>>> >>>> Error in parse query :The light of the body is the eye: if >>>> therefore thine eye be single, thy whole body shall be full of >>>> light. But if thine eye be evil, thy whole body shall be full >>>> of darkness. If therefore the light that is in thee be >>>> darkness, how great is that darkness! >>>> java.lang.NullPointerException >>>> >>>> Appart from [, ], (, ), whatelse should be exculded in the query? >>>> >>>> Thanks >>>> >>>> Miki >>> >>> >>> >>> -------------------------------------------------------------------- >>> - >>> 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 > > > > --------------------------------------------------------------------- > 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