djd0383 <[EMAIL PROTECTED]> wrote on 25/09/2006 11:21:13:
> Those two message print the following:
> For qtxt 1* the result query is allText:1* and
> The analyzer in use is:
> org.apache.lucene.analysis.standard.StandardAnalyzer
This output seems ok - the analyzer is standard and seems to me the result
query should be working. Are you able to modify this small stand-alone
program to create the exception you are seeing?
public static void main(String[] args) throws Exception {
// populate index with 2 docs
RAMDirectory dir = new RAMDirectory();
Analyzer anlzr = new StandardAnalyzer();
IndexWriter iw = new IndexWriter(dir,anlzr,true);
String fldName = "allText";
Document d1 = new Document();
d1.add(new Field(fldName,"This doc has no ones in
it.",Store.NO,Index.TOKENIZED));
iw.addDocument(d1);
Document d2 = new Document();
d2.add(new Field(fldName,"This doc has:
123.",Store.NO,Index.TOKENIZED));
iw.addDocument(d2);
iw.close();
String qtxt = "1*";
QueryParser qp = new QueryParser(fldName, anlzr);
Query query = qp.parse(qtxt);
System.out.println("For qtxt "+qtxt+" the result query is: " + query);
System.out.println("Analyzer: "+anlzr);
IndexSearcher searcher = new IndexSearcher(dir);
Hits hits = searcher.search(query);
if (hits==null || hits.length()==0) {
System.out.println(" NO results.");
} else {
System.out.println(" RESULTS:");
for (int i = 0; i < hits.length(); i++) {
System.out.println(" "+hits.id(i)+" - "+hits.score(i));
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]