gpt4 book ai didi

具有嵌套字段问题的 Elasticsearch 6.1 多索引搜索

转载 作者:行者123 更新时间:2023-11-29 02:56:46 25 4
gpt4 key购买 nike

我在 2 个具有嵌套字段的索引中运行多索引搜索 (elasticsearch 6.1.1),

“uniqueID”是一个嵌套字段,只存在于person索引中。

“pobox”是一个嵌套字段,只存在于地址索引中

我遇到错误:

"index": "address", "[nested] 未能找到路径 [uniqueID] 下的嵌套对象"

"index": "person", "路径[pobox]下的[nested]嵌套对象不是嵌套类型"

在我的查询中,我在个人索引中搜索字段 uniqueID,为什么我收到仅存在于地址索引中的 pobox 字段的错误。与地址索引中的搜索相同,它查找仅存在于个人索引中的 uniqueId 字段

发布http://locahost:9200/person,adress/_search

{
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"terms": {
"_index": [
"person"
]
}
},
{
"nested": {
"path": "uniqueID",
"query": {
"span_near": {
"clauses": [
{
"span_term": {
"uniqueID.uniqueID.auto": "1"
}
}
],
"slop": 3,
"in_order": true
}
}
}
}
]
}
},
{
"bool": {
"must": [
{
"terms": {
"_index": [
"adress"
]
}
},
{
"nested": {
"path": "pobox",
"query": {
"span_near": {
"clauses": [
{
"span_term": {
"pobox.pobox.auto": "1"
}
}
],
"slop": 3,
"in_order": true
}
}
}
}
]
}
}
]
}
}
}

错误

{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: { my_query }",
"index_uuid": "9Z0W-P9ZS02kJ7WmOKHPVQ",
"index": "adress"
},
{
"type": "query_shard_exception",
"reason": "failed to create query: { my_query }",
"index_uuid": "EHoxKGhdSmKoYdNgsylotw",
"index": "person"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "adress",
"node": "AEhiq0wvQTGh468sSmDN5g",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: { my_query }",
"index_uuid": "9Z0W-P9ZS02kJ7WmOKHPVQ",
"index": "adress",
"caused_by": {
"type": "illegal_state_exception",
"reason": "[nested] failed to find nested object under path [uniqueID]"
}
}
},
{
"shard": 0,
"index": "person",
"node": "AEhiq0wvQTGh468sSmDN5g",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: { my_query }",
"index_uuid": "EHoxKGhdSmKoYdNgsylotw",
"index": "person",
"caused_by": {
"type": "illegal_state_exception",
"reason": "[nested] nested object under path [pobox] is not of nested type"
}
}
}
]
},
"status": 400
}

最佳答案

那么,您尝试在一个索引上查询的嵌套结构在另一个索引上不存在,那么您期望什么?

在我看来,您应该拆分查询并使用 _msearch如果您总是需要它们。

关于具有嵌套字段问题的 Elasticsearch 6.1 多索引搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48083354/

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