制图:
{
"articles" : {
"mappings" : {
"data" : {
"properties" : {
"author" : {
"type" : "text",
"analyzer" : "standard"
},
"content" : {
"type" : "text",
"analyzer" : "english"
},
"tags" : {
"type" : "keyword"
},
"title" : {
"type" : "text",
"analyzer" : "english"
}
}
}
}
}
}
示例数据:
{
"author": "John Smith",
"title": "Hello world",
"content": "This is some example article",
"tags": ["programming", "life"]
}
所以你看到我在不同的领域用不同的分析器进行映射 . 现在我想以下列方式搜索这些字段:
-
仅返回匹配 all 搜索关键字的文档(例如multi_match,其中cross_fields作为类型和作为运算符)
-
查询应该是模糊的,因此它可以容忍一些拼写错误
-
不同的字段应该有不同的提升值(例如 Headers 比内容更重要)
例如,以下查询应与上述文档匹配:
programing worlds john examlpe
我该怎么做?根据documentation模糊赢得't work with cross_fields nor fields with different analysers. One way of doing it would be implementing custom _all fields and coping all values there using copy_to but with this approach I can' t分配不同的权重也不使用不同的分析器 .