gpt4 book ai didi

elasticsearch - Elasticsearch 查询词返回所有数据

转载 作者:行者123 更新时间:2023-12-03 00:59:53 25 4
gpt4 key购买 nike

我正在尝试查询我的ES,这是我的数据,
您可以在某种意义上运行它,它创建索引fst并将其填充4个项目。
那么您会看到它返回了错误的结果编号
我只需要一个结果,应该是这样。

PUT fst/objects/ggg
{
"frameAttributes": {
"identities": [
{ "_id": "DSC00263", "_score": 0.655822},
{ "_id": "DSC00262", "_score": 0.59957 },
{ "_id": "DSC00244", "_score": 0.220819},
{ "_id": "DSC00300", "_score": 0.191191},
{"_id": "DSC00276", "_score": 0.124561}

]
}
}
PUT fst/objects/ffffff
{
"frameAttributes": {
"identities": [
{"_id": "DSC00222","_score": 0.191009},
{"_id": "DSC00261","_score": 0.146157},
{"_id": "DSC00329","_score": 0.14518},
{"_id": "DSC00225","_score": 0.12622},
{"_id": "DSC00295","_score": 0.12396}
]
}

}
PUT fst/objects/aaaa
{
"frameAttributes": {
"identities": [
{"_id": "DSC00229","_score": 0.223149},
{"_id": "DSC00240","_score": 0.178388},
{"_id": "DSC00228","_score": 0.173769},
{"_id": "DSC00257","_score": 0.166746},
{"_id": "DSC00226","_score": 0.153071}
]
}
}
put fst/objects/abcdef
{
"frameAttributes": {
"identities": [
{ "_id": "DSC00262","_score": 0.427957},
{"_id": "DSC00263","_score": 0.408772},
{"_id": "DSC00282","_score": 0.284546 },
{ "_id": "DSC00283","_score": 0.191374},
{"_id": "DSC00299", "_score": 0.165478}
]
}
}

我的查询应仅返回一个结果
get fst/_search
{
"query": {
"term": {
"frameAttributes.identities._id": {
"value": "DSC00229"
}
}
}
}

最佳答案

您必须将必填字段设置为not_analyzed。在您的情况下,该字段为_id。您可以在创建索引时执行此操作。例如:

PUT /gb/_mapping/tweet
{
"properties" : {
"tag" : {
"type" : "string",
"index": "not_analyzed"
}
}
}

检查此链接以供引用: https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html

关于elasticsearch - Elasticsearch 查询词返回所有数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39479208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com