RavenDB全文搜索

编程入门 行业动态 更新时间:2024-10-25 08:28:06
本文介绍了RavenDB全文搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您能否告诉我们如何在 RavenDb 中执行简单的全文搜索。该数据库存储文件:电影{名称=加勒比海盗} 。我希望这个文件可以在搜索短语Pirates Carribean或任何其他词汇组合中找到。

担心与全文无关 - 默认情况下,Lucene以OR为基础,你想要的是一个AND

如果我是你,我会做

String [] terms = searchTerm.Split(); //或者任何string.split方法是

$ b (Name :(+ String.Join(AND,terms)+)); $ b

.Where

您的索引应该类似于

<$ p $ b $ public class Movie_ByName:AbstractIndexCreationTask { public override IndexDefinition CreateIndexDefinition() { return new IndexDefinitionBuilder< Movie> { Map = movies => from movie in movies select new {movie.Name,market.Id}, Indexes = { {x => x.Name,FieldIndexing.Analyzed} } } .ToIndexDefinition(DocumentStore.Conventions); }

你不需要存储,你不需要从lucene直接在任何时间。你可能甚至不需要索引(你可能真的想要FieldIndexing.Analyzed,并可能在这里只使用动态查询)

尽管如此。

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.

解决方案

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

String[] terms = searchTerm.Split(" "); // Or whatever the string.split method is

and

.Where("Name:(" + String.Join(" AND ", terms) + ")");

Your index should look something like

public class Movie_ByName : AbstractIndexCreationTask { public override IndexDefinition CreateIndexDefinition() { return new IndexDefinitionBuilder<Movie> { Map = movies => from movie in movies select new { movie.Name, market.Id }, Indexes = { {x => x.Name, FieldIndexing.Analyzed} } } .ToIndexDefinition(DocumentStore.Conventions); }

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.

更多推荐

RavenDB全文搜索

本文发布于:2023-10-18 23:51:10,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:全文   RavenDB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!