Hey Guys
Found some Highlighter Package on CVS
Directory
Was
Investigating,found some Compile time
error..
Please some body tell me what
this
The
Code:-
private IndexReader reader=null;
private Highlighter highlighter = null;
public SearchFiles() {
}
public void searchIndex0(String srchkey,String pathfile)throws Exception {
IndexSearcher searcher = new IndexSearcher(pathfile);
Query query = QueryParser.parse(srchkey,"bookid", analyzer);
query=query.rewrite(reader); //required to expand search terms
Hits hits = searcher.search(query);
highlighter = new Highlighter(this,new QueryScorer(query));
for (int i = 0; i < hits.length(); i++) {
String text = hits.doc(i).get(bookid);
TokenStream tokenStream=analyzer.tokenStream(bookid,new StringReader(text));
// Get 3 best fragments and seperate with a "..."
String result = highlighter.getBestFragments(tokenStream,text,3,"...");
System.out.println(result);
}
}
private Highlighter highlighter = null;
public SearchFiles() {
}
public void searchIndex0(String srchkey,String pathfile)throws Exception {
IndexSearcher searcher = new IndexSearcher(pathfile);
Query query = QueryParser.parse(srchkey,"bookid", analyzer);
query=query.rewrite(reader); //required to expand search terms
Hits hits = searcher.search(query);
highlighter = new Highlighter(this,new QueryScorer(query));
for (int i = 0; i < hits.length(); i++) {
String text = hits.doc(i).get(bookid);
TokenStream tokenStream=analyzer.tokenStream(bookid,new StringReader(text));
// Get 3 best fragments and seperate with a "..."
String result = highlighter.getBestFragments(tokenStream,text,3,"...");
System.out.println(result);
}
}
The
Error:-
src\org\apache\lucene\search\higlight\SearchFiles.java:46:
cannot resolve symbol
symbol : constructor Highlighter (com.controlnet.higlight.SearchFiles,com.controlnet.higlight.QueryScorer)
location: class org.apache.lucene.search.highlight.Highlighter highlighter =new Highlighter(this,new QueryScorer(query));
symbol : constructor Highlighter (com.controlnet.higlight.SearchFiles,com.controlnet.higlight.QueryScorer)
location: class org.apache.lucene.search.highlight.Highlighter highlighter =new Highlighter(this,new QueryScorer(query));
Also Reffrells to URL from archives lucene-dev is not avaliable for proper documentation
http://home.clara.net/markharwood/lucene/highlight.htm
HAVE A NICE DAY [ N.S.KARTHIK] |