Is there any Lucene highlighter that does not require the original text - but rather can work on term positions etc

柔情痞子 提交于 2019-12-06 06:39:45

问题


I have been reading the new 2nd edition of the Lucene in Action and they give an example of doing highlighting but unfortunately it requires the original text so it can get the position of terms etc. The highlighter is the official one in contrib, so that implies its the sponsorted or official highlighter.

Does anyone know of another highlighter that does not require the original text but works using the term positions (sorry if i got the terminology wrong) ???


回答1:


Both the standard highlighter and FastVectorHighlighter can use the index if you store the terms. (FVH can only use the index, in fact). You can see an example of this on page 274 of Lucene in Action. The relevant code line is:

TokenStream stream = TokenSources.getAnyTokenStream(searcher.getIndexReader(), sd.doc, "title", doc, analyzer);

That will get the token stream from the index.



来源:https://stackoverflow.com/questions/3784495/is-there-any-lucene-highlighter-that-does-not-require-the-original-text-but-ra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!