java - lucene get matched terms in query -


Most of the information about which words are found in a query compared to the returned document as a hit in Lucene What's the best way?

I have tried a strange method associated with the hit highlighting package in lucene contrib, and it is also a method that queries every word in the query against the top most document ("docId: xy and description: every_word_in_query") Explores.

Do not get satisfactory results? Hit highlighting does not report some words that first correspond to a document other than one. I'm not sure that the second approach is the best option.

The method is one in the searcher

Illustration from Lisni in Action 2 Edition : Public class explanation {Public static zero principal (string [] algus throws an exception (if (args.length! = 2) {System.err.println ("Uses: Explanatory and Lift; Index Direct; & lt; Query & gt; "); System.exit (1);} String Index = Args [0]; String Query Expansion = Args [1]; Directory Directory = FSDirectory.open (IndexDir); query parser parser = new query user (version LUCENE_CURRENT, "content", new simple analyzer ()); query query = parser.presssexpression; System.out.println ("query:" + query expression ); Index finder explorer = new indicator finder (top); TopDocs = searcher.search (query, 10); for (int i = 0; i & lt; topdocs .lowights; i ++) {score dock match = Top Docs .coredocs [i]; Explanation Explanation = explorer.explain Eri match. Doc); Println ( "----------"); Document doctor = searcher.doc (match.doc); Println (doc.get ("title")); Println (explanation.toString ()); }}}

This will explain the score of each document that matches the query.


Comments