基于Lucene的搜索 [英] Lucene Based Searching

查看:72
本文介绍了基于Lucene的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在基于Lucene的搜索中遇到问题.我设计了一个包含五个字段的文档.将该文档视为具有地址行1,地址行2,城市,州和大头针的地址.如果要执行搜索,则搜索已在所有字段中完成,因此我正在使用布尔术语查询.因此,将可以检索结果.现在,我不仅必须使用响应来响应,还必须使用匹配字段来响应.例如,如果城市字段与搜索匹配,那么我应该回答,因为城市与搜索匹配以及实际搜索响应.是否有任何lucene api可以容纳这个?

I've a problem in Lucene based searching. I have designed a document with five fields. Consider the document be Address with addressline1, addressline2, city, state and pin. If a search is to be performed, then the search has be done in all the fields, so I'm using boolean term queries. So the results would be retrieved. Now I also have to respond not only with responses but also with the matching field. For eg if the city field matches the search, then I should respond as city matches the search along with the actual search response. Is there are any lucene api to accommodate this?

推荐答案

AFAIK没有简单的解决方案来找出与查询匹配的字段.

AFAIK there's no simple solution to find out which field matched the query.

您的选择是:

  1. 尝试使用命中荧光笔(它知道匹配发生在哪里,但是在大型结果集上明显慢了)
  2. 摆弄IndexSearcher的解释方法
  3. 构建您的自定义解决方案

恕我直言,您自己不难实现,因为Lucene在某个时间点肯定知道哪个字段产生了匹配,但是在组成您的响应时,它会将这些信息作为不必要的权重丢弃.
我偶然发现

IMHO it shouldn't be hard to implement that yourself, since Lucene in some point in time surely knows which field yielded a match, but it discards that information as unnecessary weight by the time it composes your response.
I stumbled upon this custom approach.

尝试查找更多资源最好的Lucene/Solr相关搜索引擎在search-lucene.com上.

这篇关于基于Lucene的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆