开发者

Lucene(thread) quits quietly when print hits with String.format()

开发者 https://www.devze.com 2023-04-11 17:02 出处:网络
I\'m using Lucene 3.0.3/Java 1.6 and created an index like this (each document) with the help of the WhitespaceAnalyzer:

I'm using Lucene 3.0.3/Java 1.6 and created an index like this (each document) with the help of the WhitespaceAnalyzer:

doc.add(new Field("sentence", line, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO));
doc.add(new Field("sentence-lc", line.toLowerCase(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO));

Now I want to query the index with the same analyzer like this:

Query query = parser.parse("+sentence-lc:\"" + QueryParser.escape(subjectLabel) + "\" && +sentence-lc:\"" + QueryParser.escape(objectLabel) + "\"");
开发者_开发问答ScoreDocs[] hits = indexSearcher.search(query, null, MAX_NUMBER_OF_DOCUMENTS).scoreDocs;

This works fine, but if I want to print out the number of found documents like this:

System.out.println(String.format("subject: '%s' and object: '%' returned %s index hits!", subjectLabel, objectLabel, hits.length));

the thread in which the index search runs gets killed/finished without any message/exception. Is this my mistake, java's or lucene's?

Kind regards,

Daniel

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号