Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@apache.org Received: (qmail 4511 invoked from network); 15 Aug 2002 15:12:50 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 15 Aug 2002 15:12:50 -0000 Received: (qmail 15224 invoked by uid 97); 15 Aug 2002 15:13:12 -0000 Delivered-To: qmlist-jakarta-archive-lucene-user@jakarta.apache.org Received: (qmail 15180 invoked by uid 97); 15 Aug 2002 15:13:11 -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 15168 invoked by uid 98); 15 Aug 2002 15:13:11 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: Thu, 15 Aug 2002 17:12:44 +0200 From: Bjoern Feustel To: lucene-user@jakarta.apache.org Subject: WildcardQuery (and FuzzyQuery) problems or bugs? Message-ID: <20020815151244.GC1168@espresto.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="X1xGqyAVbSpAWs5A" Content-Disposition: inline User-Agent: Mutt/1.3.27i X-Editor: VIM - Vi IMproved 6.0ax BETA X-Mailer: Mutt 1.3.27i X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --X1xGqyAVbSpAWs5A Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, i've got problems while using wildcard and fuzzy searches. While indexing a bunch of documents it could happen that a field of all documents will be left empty (empty String). I don't know wether this field will be included into the index at all. But this leads to a problem while searching. If i create some Queries (actually this does the QueryParser for me) on that field and run a search with these queries, i would expect no results. However, WildcardQuery and FuzziQuery sometimes generate a NullPointerException in WildcardTermEnum.termCompare(...). It seems to me that this does not happen if i add an additional unused field to all documents but it may be that this works for me due to other reasons. To explain what i mean, i've attached some lines of test code. btw: I'm using lucene nightly-build 20020814. Am i missing something or is this a bug? Another question: An WildcardQuery that is constructed of only non-wildcards gives me an StringIndexOutOfBoundsException while searching. Shouldn't this be handled in a smarter way? Thanks in advance, Bjoern --X1xGqyAVbSpAWs5A Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="Tester.java" import org.apache.lucene.search.*; import org.apache.lucene.index.*; import org.apache.lucene.store.*; import org.apache.lucene.analysis.*; import org.apache.lucene.document.*; import org.apache.lucene.queryParser.*; public class Tester { public void testMe (boolean additionalField) throws Exception { RAMDirectory indexStore = new RAMDirectory(); IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true); Document doc = new Document(); doc.add(Field.Text("bar0", "foo")); doc.add(Field.Text("bar1", "")); // magical unused extra field if (additionalField) doc.add(Field.Text("bar2", "foo")); writer.addDocument(doc); writer.optimize(); writer.close(); IndexSearcher searcher = new IndexSearcher(indexStore); Query[] queries = new Query[3]; queries[0] = new WildcardQuery(new Term("bar0", "f?o")); // works as expected queries[1] = new TermQuery(new Term("bar1", "foo")); // this one too queries[2] = new WildcardQuery(new Term("bar1", "f?o")); // strange Hits result; for (int q = 0; q < queries.length; q++) { System.out.println ("Query " + q + " (" + queries[q].getClass().getName() + ")"); System.out.println ("\ttoString (\"bar0\") = " + queries[q].toString ("bar0")); System.out.println ("\ttoString (\"bar1\") = " + queries[q].toString ("bar1")); result = searcher.search(queries[q]); if (result.length() == 0) { System.out.println ("\tno results"); } for (int i = 0; i < result.length(); i++) { Document d = result.doc(i); System.out.println ("\tresult: " + d.get ("bar0") + " - " + d.get ("bar1")); } } } public static void main(String[] _argv) { Tester t = new Tester(); try { System.out.println ("## With additional unused extra field it works"); t.testMe(true); } catch (Throwable th) { System.err.println ("OOPS: " + th.getMessage()); th.printStackTrace(); } try { System.out.println ("\n## Without additional unused extra field it won't work"); t.testMe(false); } catch (Throwable th) { System.err.println ("OOPS: " + th.getMessage()); th.printStackTrace(); } } } --X1xGqyAVbSpAWs5A Content-Type: text/plain; charset=us-ascii -- To unsubscribe, e-mail: For additional commands, e-mail: --X1xGqyAVbSpAWs5A--