lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arpad KATONA" <a.kat...@ever-team.com>
Subject QueryParser KEY:[2-3] returns 1 hit ...
Date Wed, 26 Mar 2003 08:14:25 GMT
Hello Lucene Users,

could you look at this code sample below please :

String sIxPath="d:/lucene/index;
StandardAnalyzer azer=new StandardAnalyzer();
IndexWriter writer = new IndexWriter(sIxPath, azer, true);
boolean bSto=false, bIx=true, bTok=false;
Document doc; Field fd;

doc = new Document();
doc.add(new Field("KEY", "1", true, bIx, bTok));
doc.add(new Field("DBName", "base01", bSto, bIx, bTok));
doc.add(new Field("TableName", "table01", bSto, bIx, bTok));
doc.add(new Field("AUTHOR", "author01", bSto, bIx, bTok));
doc.add(new Field("TITLE", "title01", bSto, bIx, bTok));
writer.addDocument(doc);
doc = new Document();
doc.add(new Field("KEY", "2", true, bIx, bTok));
doc.add(new Field("DBName", "base01", bSto, bIx, bTok));
doc.add(new Field("TableName", "table01", bSto, bIx, bTok));
doc.add(new Field("AUTHOR", "author02", bSto, bIx, bTok));
doc.add(new Field("TITLE", "title02", bSto, bIx, bTok));
writer.addDocument(doc);
doc = new Document();
doc.add(new Field("KEY", "3", true, bIx, bTok));
doc.add(new Field("DBName", "base01", bSto, bIx, bTok));
doc.add(new Field("TableName", "table01", bSto, bIx, bTok));
doc.add(new Field("AUTHOR", "author03", bSto, bIx, bTok));
doc.add(new Field("TITLE", "title03", bSto, bIx, bTok));
writer.addDocument(doc);
writer.close();

Searcher searcher = new IndexSearcher(sIxPath);
String sQuery="KEY:[2-3] AND DBName:base01 AND TableName:table01";
Query query = QueryParser.parse(sQuery, "KEY", azer);
System.out.println("query = '"+query.toString("")+"'");
Hits hits = searcher.search(query);
int nbHits = (hits==null) ? (-1) : (hits.length());
System.out.println("nbHits = "+Integer.toString(nbHits));
for(int ix=0; ix<nbHits; ix++) {
  doc = hits.doc(ix);
  fd=doc.getField("KEY");
  String sVal = fd.stringValue();
  System.out.println("KEY="+sVal);
}
hits = null;
query = null;
searcher.close(); searcher=null;

on the output appears :

query = '+KEY:[2-3-null] +DBName:base01 +TableName:table01'
nbHits = 1
KEY=3

what's wrong, please ? Is it perhaps a bug Lucene ?

Thanx

Arpad KATONA
---
a.katona@ever-team.com


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message