Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@apache.org Received: (qmail 46423 invoked from network); 14 Jul 2003 08:26:17 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 14 Jul 2003 08:26:17 -0000 Received: (qmail 14130 invoked by uid 97); 14 Jul 2003 08:28:57 -0000 Delivered-To: qmlist-jakarta-archive-lucene-user@nagoya.betaversion.org Received: (qmail 14123 invoked from network); 14 Jul 2003 08:28:57 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 14 Jul 2003 08:28:57 -0000 Received: (qmail 46108 invoked by uid 500); 14 Jul 2003 08:26:14 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 46090 invoked from network); 14 Jul 2003 08:26:13 -0000 Received: from bosvwl02.itlinfosys.com (HELO bosvwl02.infosys.com) (216.52.49.36) by daedalus.apache.org with SMTP; 14 Jul 2003 08:26:13 -0000 Received: from 192.168.200.83 by bosvwl02.infosys.com (InterScan E-Mail VirusWall NT); Mon, 14 Jul 2003 04:28:12 -0400 Received: from kecmsg07.ad.infosys.com ([192.168.200.68]) by INDHUBBHS03.ad.infosys.com with Microsoft SMTPSVC(5.0.2195.5329); Mon, 14 Jul 2003 13:54:40 +0530 Received: from kecmsg03.ad.infosys.com ([192.168.200.70]) by kecmsg07.ad.infosys.com with Microsoft SMTPSVC(5.0.2195.5329); Mon, 14 Jul 2003 13:54:39 +0530 X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: HELP in QueyParsing !! Date: Mon, 14 Jul 2003 13:54:39 +0530 Message-ID: <9002F5518DF72C4B869259B65E81D8540F5467AA@kecmsg03.ad.infosys.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: HELP in QueyParsing !! Thread-Index: AcNJ4V1DonyTQhnOToOheonSPIMkWA== From: "Bharatbhushan_Shetty" To: "Lucene Users List" Cc: X-OriginalArrivalTime: 14 Jul 2003 08:24:39.0524 (UTC) FILETIME=[5E4F7240:01C349E1] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi=20 Need some help in queryparsing. There are few things that doesn't Seem to work as I expected. Have a look at the code at the end=20 Before reading my observations. Document contains following information: D1 =3D c++ hello bharat D2 =3D c hello sharat=20 D3 =3D hello bharat Observations =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Input: QueryCreated Remarks c\+\+ c (Escape character not working) c++ - (Parser throws an exception) [NOTE-1] c* c* (Wild card works perfectly fine) *c - (throws an exception - [NOTE-2] (org.apache.lucene.queryParser.TokenMgrError:) "c - (throws an exception - [NOTE-3] Hello "" - (throws an exception) [NOTE-1] : - ( ) { } ! [ ] etc characters behave in the same manner=20 as "+" shown above. [NOTE-2] : Looks like wildcard cannot be the first character of the query [NOTE-3] : I guess this validation can be done after accepting user input.=20 My Comments/Questions =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Does that mean that the program should taken care of validating the=20 User input and then pass the query string to QueryParser? If yes, I guess there might be some more validations that should be=20 Done that I have missed out. Can anyone throw some light on those Validations that the program should take care? Code =3D=3D=3D=3D import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.*; import org.apache.lucene.document.*; import org.apache.lucene.index.*; import org.apache.lucene.search.*; public class TestQueryParser { public static void main(String[] argv) { try { IndexWriter writer =3D new IndexWriter("indexbbs", new StandardAnalyzer(), true); =20 Document d1 =3D new Document(); d1.add(Field.Text("f1", "c++ hello bharat")); writer.addDocument(d1); =20 Document d2 =3D new Document(); d2.add(Field.Text("f1", "c hello sharat")); writer.addDocument(d2); =20 Document d3 =3D new Document(); d3.add(Field.Text("f1", "hello bharat")); writer.addDocument(d3); =20 writer.optimize(); writer.close(); =20 String qString =3D ""; try { BufferedReader in =3D new BufferedReader(new InputStreamReader(System.in)); System.out.print("Input for f1: "); qString =3D in.readLine(); } catch(Exception e) { System.out.println("Exiting..." + e.getMessage()); return; } =20 System.out.println(""); =20 Searcher searcher =3D new IndexSearcher("indexbbs"); Analyzer analyzer =3D new StandardAnalyzer(); QueryParser qp =3D new QueryParser("f1", analyzer); =20 Query query =3D qp.parse(qString); =20 System.out.println("QueryInput:" + qString); System.out.println("QueryCreated:" + query.toString("f1")); =20 Hits hits =3D searcher.search(query); for (int i=3D0; i