【发布时间】:2017-11-20 13:42:18
【问题描述】:
我在 Elasticsearch 5.5 中使用 multi_match 和 phrase_prefix 进行全文搜索。 ES 查询看起来像
{
query: {
bool: {
must: {
multi_match: {
query: "butt",
type: "phrase_prefix",
fields: ["item.name", "item.keywords"],
max_expansions: 10
}
}
}
}
}
我收到以下回复
[
{
"_index": "items_index",
"_type": "item",
"_id": "2",
"_score": 0.61426216,
"_source": {
"item": {
"keywords": "amul butter, milk, butter milk, flavoured",
"name": "Flavoured Butter"
}
}
},
{
"_index": "items_index",
"_type": "item",
"_id": "1",
"_score": 0.39063013,
"_source": {
"item": {
"keywords": "amul butter, milk, butter milk",
"name": "Butter Milk"
}
}
}
]
映射如下(我使用的是默认映射)
{
"items_index" : {
"mappings" : {
"parent_doc": {
...
"properties": {
"item" : {
"properties" : {
"keywords" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
}
item 和 "name": "Flavoured Butter" 如何相对于带有"name": "Butter Milk" 和得分0.39063013 的文档获得更高的0.61426216 分数?
我尝试将 boost 应用于 "item.name" 并删除 "item.keywords" 表单搜索字段以获得相同的结果。
Elasticsearch 中的分数如何运作?就相关性而言,上述结果是否正确?
【问题讨论】:
-
能给我们提供索引的映射吗?因为对于带有
"name": "Flavoured Butter"的文档,我得到了不同的得分值0.37598053 -
@ChandraPraneethN 我正在使用默认映射(有问题添加)。唯一的问题是
item是嵌套在其父级中的文档,但这应该没有任何区别。
标签: elasticsearch elasticsearch-5