0

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"));
}
inverted_index
  • 2,329
  • 21
  • 40
drag
  • 73
  • 7
  • This code does not make a lot of sense to me. The `a` list should be a list of fields in your schema, but you seem to have the words of some sentence. Please explain what you want that query to do. Is this supposed to be a phrase search? A search for multiple words? – Stephen C Oct 25 '16 at 02:59
  • I want to search it for multiple words . My Schema include fields "context","fileName", "filePath" . Do you have some suggest for me . Thanks – drag Oct 25 '16 at 08:31

0 Answers0