ElasticSearch将多个字段视为模糊查询

时间:2016-05-10 16:37:00

标签: elasticsearch lucene

{
    "title" : "That Uselessly Amazing Title",
    "author" : "Someone you have never heard of",
    "url" : "http://www.theuselessweb.com",
    "summary" : "a collection of useless websites",
    "tag" : ["useless","maybe useful"]
}  

假设我有一个类似上面显示的架构。用户要求应用程序显示某些内容"无用"。

如何编写查询,查看单词的标题,摘要和标签"无用"作为模糊搜索?

1 个答案:

答案 0 :(得分:1)

来自文档Fuzzy match Query

A

此查询有效,因为它使用// Select all the File objects from EF DbSet<File> that you want to delete and store in a List<File>. var toDelete = context.Files.Where(predicate).ToList(); //loop through the list and remove each one or i think there is a RemoveRange method. var deleted = context.Files.RemoveRage(toDelete); //SaveChanges on your DbContext if(context.SaveChanges() == toDelete.Count) { //and then you can loop through your List and delete the files from system deleted.ToList().ForEach(file => { var fileInfo = new FileInfo(file.SystemFileName); if(fileInfo.Exists) { fileInfo.Delete(); } }); } 查询

  

模糊性仅适用于基本的GET /my_index/my_type/_search { "query": { "multi_match": { "fields": [ "summary", "title", "tag" ], "query": "useless", "fuzziness": "AUTO" } } } multi_match查询。它   不适用于词组匹配,常用术语或match   匹配。

否则,您必须在multi_match查询中combine多次cross_fields次查询

相关问题