我正在尝试查询我的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"
}
}
}
}发布于 2016-09-20 16:33:06
我花了一段时间,但我学到了一些新的elastic search不喜欢你创建一个名为_id的字段。我将其更改为personId,现在它可以正常工作了。
感谢所有人:)
发布于 2016-09-14 07:24:10
您必须将必填字段设置为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
https://stackoverflow.com/questions/39479208
复制相似问题