在Lucene的搜索短语 [英] Searching phrases in Lucene

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

问题描述

可能有人点我的例子如何为短语搜索与Lucene.net?

Could somebody point me to an example how to search for phrases with Lucene.net?

比方说,我有我的索引与场名的文件,值全碟。现在,我希望能够搜索乔恩斯基特时找到该文件。

Let's say I have in my index a document with field "name", value "Jon Skeet". Now I want to be able to find that document when searching for "jon skeet".

推荐答案

您可以使用的邻近搜索找到对方的一定距离内条款。 Lucene的查询语法看起来像这样乔恩斯基特〜3 ,意思是找到乔恩,并在对方的三个词飞碟。有了这个语法,相对顺序并不重要; 乔恩。问飞碟,飞碟,Q。乔恩和全碟将所有的比赛。

You can use a proximity search to find terms within a certain distance of each other. The Lucene query syntax looks like this "jon skeet"~3, meaning find "jon" and "skeet" within three words of each other. With this syntax, relative order doesn't matter; "jon q. skeet", "skeet, q. jon", and "jon skeet" would all match.

如果你有,你要视为单个标记短语列表,你需要照顾,在你的分析仪。例如,你要正确对待近东,中东和远东作为单独的令牌。你需要写一个分析一些向前看,这样它可以把这些短语,好像他们是一个词。该分析仪在索引中搜索应用同时使用,并且针对用户的输入。

If you have a list of phrases that you want to treat as a single token, you need to take care of that in your analyzer. For instance, you want to treat "near east", "middle east", and "far east" as individual tokens. You need to write an analyzer with some lookahead, so that it can treat these phrases as if they were one word. This analyzer is used both in the indexer, and against user input in the search application.

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

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