I was learning to seach query performed on a text document. But language is not English. I have to learn and use it, But BooleanQuery
and MultiFieldQueryParser
not run in Lucene 6.2.0.
example:
Sentence Query : Tôi đang đi học
Document: ..Tôi là một sinh viên chăm chỉ. Tôi đang học bài ở thư viện trung tâm. Nhưng mẹ tôi gọi về nhà..
How can I search query in documents.
String a[] = token.tachtu(sentence).split(" ");// segment sentence into words
String field[] = null;
field[0] = "contents";
MultiFieldQueryParser multifieldQP = new MultiFieldQueryParser(a, new WhitespaceAnalyzer());
Query query = multifieldQP.parse(a,field,new WhitespaceAnalyzer());
TopDocs topDocs = isearcher.search(query, 10);
System.out.println("totalHits " + topDocs.totalHits);
for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
org.apache.lucene.document.Document document = isearcher.doc(scoreDoc.doc);
System.out.println("path " + document.get("path"));
//System.out.println("content " + document.get("contents"));
}