DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=30977>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=30977 "and" should be used in query syntax, not "AND" [EMAIL PROTECTED] changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|WORKSFORME | ------- Additional Comments From [EMAIL PROTECTED] 2004-09-29 21:19 ------- I wish to reopen this issue. Lucene gives different results when using "and" and "AND". Bellow is the runable class IndexItems and SearchItems. package test; import java.io.IOException; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; public class IndexItems { public static void main(String[] args) throws IOException { try { IndexWriter writer = new IndexWriter("/test/index", new StandardAnalyzer (), true); indexDocs(writer); writer.optimize(); writer.close(); System.out.println("index finished."); } catch (IOException e) { System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } } private static void indexDocs(IndexWriter writer) throws IOException { Document document=new Document(); document.add(Field.Keyword("type", "stockSingle")); document.add(Field.Text("desc", "test single 1")); writer.addDocument(document); document.add(Field.Keyword("type", "stockSingle")); document.add(Field.Text("desc", "test single 2")); writer.addDocument(document); document.add(Field.Keyword("type", "stockSingle")); document.add(Field.Text("desc", "test single 3")); writer.addDocument(document); } } package test; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.search.Searcher; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.Hits; import org.apache.lucene.queryParser.QueryParser; public class SearchItems { public static void main(String[] args) { try { Searcher searcher = new IndexSearcher("/test/index"); Analyzer analyzer = new StandardAnalyzer(); QueryParser qp=new QueryParser("desc", new StandardAnalyzer()); // Query query1=qp.parse("(type:stockSingle) test"); // Query query2=qp.parse("type:stockSingle and test"); Query query1=QueryParser.parse("type:stockItem AND desc:test", "desc", new StandardAnalyzer()); Query query2=QueryParser.parse("type:stockItem and desc:test", "desc", new StandardAnalyzer()); Hits hits = searcher.search(query1); System.out.println("search using AND: "+hits.length() + " total matching documents"); hits = searcher.search(query2); System.out.println("search using and: "+hits.length() + " total matching documents"); searcher.close(); } catch (Exception e) { System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]