Lucene Highlighter linkage Error
Hello!
I am working with Tomcat. I have put the Lucene highlighter.jar in the folder lib. And I have created an extra css, where I say that the background color has to be yellow. The searchword has to be highlighted know.
I have got a dataTable in which the result of the following Lucene method is loaded:
publicvoid search(String q, File index, String [] fields, ArrayList subresult,int numresults)throws Exception{
Directory fsDir = FSDirectory.getDirectory(index,false);
IndexSearcher is =new IndexSearcher(fsDir);
Analyzer analyzer =new StandardAnalyzer();
Fragmenter fragmenter =new SimpleFragmenter(100);
QueryParser queryparser =new MultiFieldQueryParser (fields, analyzer);
Query query = queryparser.parse(q);
Hits hits = is.search(query);
IndexReader reader=null;
query=query.rewrite(reader);
QueryScorer scorer =new QueryScorer(query);
[code]
SimpleHTMLFormatter formatter= new SimpleHTMLFormatter("<span class=\"highlight\">","</span>");
Highlighter high = new Highlighter(formatter,scorer);
high.setTextFragmenter(fragmenter);
numresults = numresults == -1 || numresults > hits.length() ? hits.length() : numresults;
String rating = "";
for (int i = 0; i <numresults; i++) {
if (hits.score(i)>schwelli){
float f = hits.score(i);
if (0.9f <= f) {rating = "******";}
else if (0.8f <= f && f<0.9f){rating = "*****";}
else if (0.7f <= f && f<0.8f){rating = "****";}
else if (0.6f <= f && f<0.7f){rating = "***";}
else if (0.5f <= f && f<0.6f){rating = "**";}
else if (f <= 0.5f){rating = "*";}
Document doc = hits.doc(i);
String abstracts =doc.get("ABSTRACTS");
String title = doc.get("TITLE");
TokenStream abstract_stream = analyzer.tokenStream(q, new StringReader(abstracts));
TokenStream title_straem = analyzer.tokenStream(q, new StringReader(title));
String fragment_abstract = high.getBestFragments(abstract_stream,abstracts, 5, "...");
String fragment_title = high.getBestFragments(title_straem,title, 5, "...");
if(fragment_title.length()==0){
setAusgabeTitle(doc.get("TITLE"));
}else{
setAusgabeTitle(fragment_title);
}
if(fragment_abstract.length()==0){
setAusgabeAbstract(doc.get("ABSTRACTS"));
}else{
setAusgabeAbstract(fragment_abstract);
}
//list.add(i+1+"\t"+q+"\t"+doc.get(entry_medline)+"\t"+hits.score(i)+"\t"+abstract_stream+"\t"+title_straem+"\t"+"MEDLINE");
/*int No = i;
subresult.add((new Integer(No)).toString());*/
subresult.add(doc.get(entry_medline));
subresult.add("No Id");
subresult.add("No Id");
float sco = hits.score(i);
subresult.add(rating);//(hits.score(i));
subresult.add(abstract-stream);
subresult.add(title_straem);
subresult.add("No hits for this index");
subresult.add("MEDLINE");
}
}
}
[code]
But I get the following error.
Error:
javax.servlet.ServletException: #{suggestBox.Search}: javax.faces.el.EvaluationException: java.lang.LinkageError: Class org/apache/lucene/search/Query violates loader constraints
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.j ava:96)
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
Does someone know what I am doing wrong?

