RavenDB 全文搜索
您能告诉我如何在RavenDb中执行简单的全文搜索吗?数据库存储文档:Movie {Name = "Pirates of the Carribean"}。我希望在搜索短语“加勒比海盗”或任何其他单词组合中找到该文档。
Can you please tell how to perform simple full-text search in RavenDb. The database is stored document: Movie {Name = "Pirates of the Carribean"}. I wish that this document was found on the search phrase "Pirates Carribean" or any other combination of words.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
鲍里斯,
Rob的答案有正确的索引,但查询起来有点尴尬。您可以使用以下方法来做到这一点
:
Boris,
Rob's answer has the right index, but it is a bit awkward for querying. You can do that using:
That will
你担心的与全文无关 - 默认情况下 Lucene 在 OR 基础上工作,你想要的是 AND
如果我是你,我会这样做
,
你的索引应该看起来像
You don't need存储,您在任何时候都不会直接从 lucene 请求数据。您甚至可能不需要索引(您实际上可能需要 FieldIndexing.Analyzed,并且可能只需要在此处使用动态查询)
即可。不过,这取决于您。
What you are worrying about isn't anything to do with full text - by default Lucene works on an OR basis and what you want is an AND
If I were you I'd do
and
Your index should look something like
You don't need storage, you're not requesting the data from lucene directly at any time. You might not even want an index (You might actually want FieldIndexing.Analyzed, and might get away with just using dynamic queries here)
Up to you though.
以下是我如何实现“ANDing”术语搜索。
首先,确保您的字段已被索引和分析:
然后从客户端查询:
Here's how I acheived an "ANDing" term search.
First, make sure that your field is indexed and analyzed:
Then query from the client: