【发布时间】:2020-10-11 02:06:17
【问题描述】:
如何制作搜索通配符和 tf-idf 分数。 例如当我这样搜索时,
GET /test_es/_search?explain=true // return idf / dt scores
{
"explain":true,
"query": {
"query_string": {
"query": "bar^5",
"fields" : ["field"]
}
}
}
它返回 idf 和 td 分数, 但是当我使用通配符(包含)进行搜索时。
GET /test_es/_search?explain=true // NOT RETURN idf/td score
{
"explain":true,
"query": {
"query_string": {
"query": "b*",
"fields" : ["field"]
}
}
}
如何使用通配符进行搜索(在字符串中使用 contains)并包含 IDF-TD 分数?
例如,我有 3 个文档 “foo”、“foo bar”、“foo baz” 当我这样搜索时
GET /foo2/_search?explain=true
{
"explain":true,
"query": {
"query_string": {
"query": "fo *",
"fields" : ["field"]
}
}
}
弹性搜索结果
"hits" : [
{
"_shard" : "[foo2][0]",
"_node" : "z8bjI0T1T8Oq6Z2OwFyIKw",
"_index" : "foo2",
"_type" : "_doc",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"field" : "foo bar"
},
"_explanation" : {
"value" : 1.0,
"description" : "sum of:",
"details" : [
{
"value" : 1.0,
"description" : "*:*",
"details" : [ ]
}
]
}
},
{
"_shard" : "[foo2][0]",
"_node" : "z8bjI0T1T8Oq6Z2OwFyIKw",
"_index" : "foo2",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"field" : "foo"
},
"_explanation" : {
"value" : 1.0,
"description" : "sum of:",
"details" : [
{
"value" : 1.0,
"description" : "*:*",
"details" : [ ]
}
]
}
},
{
"_shard" : "[foo2][0]",
"_node" : "z8bjI0T1T8Oq6Z2OwFyIKw",
"_index" : "foo2",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"field" : "foo baz"
},
"_explanation" : {
"value" : 1.0,
"description" : "sum of:",
"details" : [
{
"value" : 1.0,
"description" : "*:*",
"details" : [ ]
}
]
}
}
]
但我认为“foo”应该是第一个得分最高的结果,因为它匹配 %100,我错了吗?
【问题讨论】:
-
令人困惑。您希望
idf-td出现在结果中还是希望获得特定的分数?
标签: elasticsearch wildcard tf-idf elasticsearch-query