我正在尝试为包含文本文章中存储的信息的网站构建合理的搜索机制。我正在 umbraco lucene 的检查中进行搜索。
所以,假设我正在搜索的字段是“bodyText”和“titleText”,
我为过滤器想出的是这样的:
var filter = criteria
.GroupedOr(new string[] { "bodyText","titleText"}, SearchTerm)
.Compile();
更好的搜索的示例是什么,例如,其中包括包含 SearchTerm 的结果(“literate”将是“iter”搜索的结果),或该搜索的任何其他改进?
最佳答案
你尝试过Fuzzy()
吗?
来自http://umbraco.com/follow-us/blog-archive/2011/9/16/examining-examine.aspx
Sometimes users will query your site looking for a term that they could have misspelled or is very close. Fuzzy gives you the ability to get Lucene to look for terms that look like your term. Eg mound could actually be sound.
var query = searchCriteria.Fields("nodeName","hello".Fuzzy(0.8)).Compile();
The optional value you pass into Fuzzy between 0 and 1 specifies how Fuzzy or how close the match is to the original. For instance a match of 0.5 will not return when a threshold of 0.8 is specified.
我不太确定语法是否正确,但可以尝试一下。它实际上可能不会进行部分单词搜索,但可能会提供更接近您要查找的结果。
关于full-text-search - Lucene 检查的搜索条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8273044/