问题描述
目前,我正在使用 Lucene 版本 3.0.2 创建一个类似于字典的搜索应用程序.我要显示的对象之一是一种示例",Lucene 会在其中查找书中的一个单词,然后显示使用这些单词的句子.
Currently, I am using Lucene version 3.0.2 to create a search application that is similar to a dictionary. One of the objects that I want to display is a sort of "example", where Lucene would look for a word in a book and then the sentences where the words were used are displayed.
我一直在阅读 Lucene in Action 这本书,其中提到了类似的内容,但通过它我找不到其他提及.这是你可以用 Lucene 做的事情吗?如果是,你是怎么做到的?
I've been reading the Lucene in Action book and it mentions something like this, but looking through it I can't find other mentions. Is this something you can do with Lucene? If it is, how is can you do it?
推荐答案
我相信您正在寻找的是荧光笔.
I believe what you are looking for is a Highlighter.
一种可能性是使用 lucene.search.highlight 包,特别是 荧光笔.
One possibility is to use the lucene.search.highlight package, specifically the Highlighter.
另一种选择是使用 lucene.search.vectorhighlight 包,特别是 FastVectorHighlighter.
Another option is to use the lucene.search.vectorhighlight package, specifically the FastVectorHighlighter.
这两个类都搜索文本文档,选择相关的片段并显示它们,并突出显示匹配的术语.我只使用了第一个,它适用于我的用例.如果您可以将图书预先分成较短的部分,那么突出显示的速度会更快.
Both classes search a text document, choose relevant snippets and display them with the matching terms highlighted. I have only used the first one, which worked fine for my use-case. If you can pre-divide the book into shorter parts, it would make highlighting faster.
这篇关于显示来自 Lucene 搜索结果的示例文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)