elasticsearch 获取路径下的嵌套对象不是elasticsearch查询中的嵌套类型,elasticsearch,gremlin,amazon-neptune,elasticsearch,Gremlin,Amazon Neptune" /> elasticsearch 获取路径下的嵌套对象不是elasticsearch查询中的嵌套类型,elasticsearch,gremlin,amazon-neptune,elasticsearch,Gremlin,Amazon Neptune" />

elasticsearch 获取路径下的嵌套对象不是elasticsearch查询中的嵌套类型

elasticsearch 获取路径下的嵌套对象不是elasticsearch查询中的嵌套类型,elasticsearch,gremlin,amazon-neptune,elasticsearch,Gremlin,Amazon Neptune,我在尝试查询嵌套字段时遇到此错误, 这个问题似乎在重复,但变化不大,在设置字段映射时,我没有指定嵌套映射,而是创建了嵌套映射。现在,当我尝试使用gremlin查询do Neptune全文搜索查询时,它正在工作,但当我尝试执行本机查询时,它会出现以下错误: failed to create a query: [nested] nested object under path [predicates] is not of nested type 弹性搜索索引映射 { "amazon_

我在尝试查询嵌套字段时遇到此错误, 这个问题似乎在重复,但变化不大,在设置字段映射时,我没有指定嵌套映射,而是创建了嵌套映射。现在,当我尝试使用gremlin查询do Neptune全文搜索查询时,它正在工作,但当我尝试执行本机查询时,它会出现以下错误:

failed to create a query: [nested] nested object under path [predicates] is not of nested type
弹性搜索索引映射

{
  "amazon_neptune" : {
    "mappings" : {
      "properties" : {
        "aggregateId" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "document_type" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "entity_id" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "entity_type" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "predicates" : {
          "properties" : {
            "group_name" : {
              "properties" : {
                "value" : {
                  "type" : "text",
                  "analyzer" : "autocomplete_analyzer",
                  "search_analyzer" : "standard"
                }
              }
            },
            "question" : {
              "properties" : {
                "value" : {
                  "type" : "text",
                  "analyzer" : "questions_auto_complete_analyzer",
                  "search_analyzer" : "standard"
                }
              }
            },
            "suggestion" : {
              "properties" : {
                "value" : {
                  "type" : "text",
                  "analyzer" : "autocomplete_analyzer",
                  "search_analyzer" : "standard"
                }
              }
            },
            "type" : {
              "properties" : {
                "value" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                }
              }
            },
            "user_name" : {
              "properties" : {
                "value" : {
                  "type" : "text",
                  "analyzer" : "autocomplete_analyzer",
                  "search_analyzer" : "standard"
                }
              }
            }
          }
        }
      }
    }
  }
}
正在运行的小精灵查询

g.withSideEffect('Neptune#fts.endpoint',ES Endpoint).withSideEffect('Neptune#fts.queryType', 'match').V().has('suggestion','Neptune#fts life').limit(5).valueMap().toList()

Elasticsearch查询提供错误:

{
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "entity_type": "suggestions"
                    }
                },
                {
                    "term": {
                        "document_type": "vertex"
                    }
                },
                {
                    "nested": {
                        "path": "predicates",
                        "query": {
                            "nested": {
                                "path": "predicates.suggestion",
                                "query": {
                                    "match": {
                                        "predicates.suggestion.value": "life"
                                    }
                                }
                            }
                        }
                    }
                }
            ]
        }
    }
}
如果这个查询有什么问题,请告诉我

我没有指定嵌套映射,而是创建了嵌套映射

这就是问题所在。如果不显式指定type:nested,则谓词将不是嵌套类型,而是object类型,并且查询将无法正常工作

您需要显式地将谓词定义为嵌套在映射中,没有其他方法

更新

您的本机查询应如下所示:

{
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "entity_type": "suggestions"
                    }
                },
                {
                    "term": {
                        "document_type": "vertex"
                    }
                },
                {
                    "match": {
                        "predicates.suggestion.value": "life"
                    }
                }
            ]
        }
    }
}
我没有指定嵌套映射,而是创建了嵌套映射

这就是问题所在。如果不显式指定type:nested,则谓词将不是嵌套类型,而是object类型,并且查询将无法正常工作

您需要显式地将谓词定义为嵌套在映射中,没有其他方法

更新

您的本机查询应如下所示:

{
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "entity_type": "suggestions"
                    }
                },
                {
                    "term": {
                        "document_type": "vertex"
                    }
                },
                {
                    "match": {
                        "predicates.suggestion.value": "life"
                    }
                }
            ]
        }
    }
}

添加带有索引数据、映射、搜索查询和搜索结果的工作示例

索引映射:

索引数据:

运行相同的搜索查询,如问题中所示:

搜索结果:


添加带有索引数据、映射、搜索查询和搜索结果的工作示例

索引映射:

索引数据:

运行相同的搜索查询,如问题中所示:

搜索结果:


谢谢,@Val我已经试过了,效果很好。但是如果本机查询不允许,Amazon Neptune gremlin如何能够做到这一点。使用同一服务的外部工具如何能够正常工作?gremlin不能肯定地执行嵌套查询,否则也会出错。它正在执行一个正常的查询,结果可能不是您想要的结果,但gremlin正在返回预期的结果,有没有其他方法可以查询类似的内容?那么,如果正在执行非嵌套查询的gremlin返回正确的结果,为什么要在本机查询中包含嵌套查询?i、 e.你的本地查询与gremlin正在进行的查询不相等。我不知道gremlin实际上是如何在引擎盖下进行查询的,但Neptune存储数据的方式与我的相同。谢谢,@Val我已经尝试过了,工作正常。但是如果本机查询不允许,Amazon Neptune gremlin如何能够做到这一点。使用同一服务的外部工具如何能够正常工作?gremlin不能肯定地执行嵌套查询,否则也会出错。它正在执行一个正常的查询,结果可能不是您想要的结果,但gremlin正在返回预期的结果,有没有其他方法可以查询类似的内容?那么,如果正在执行非嵌套查询的gremlin返回正确的结果,为什么要在本机查询中包含嵌套查询?i、 e.你的原生查询并不等同于gremlin正在进行的查询。我不知道gremlin实际上是如何在引擎盖下进行查询的,但Neptune存储数据的方式与我的相同。如果只有一个属性,我看不出提出嵌套建议的原因。我正在为Amazon Neptune FTS实现这一点,这就是neptune在elasticsearch上的查询方式,即neptune文档中提供此模式。如果建议只有一个属性,我不认为有理由嵌套。我正在为Amazon neptune FTS实现此功能,这就是neptune在elasticsearch上的查询方式,即neptune文档中提供此模式。
 {
      "predicates": [
        {
          "suggestion": [
            {
              "value": "life"
            }
          ]
        }
      ]
    }
"hits": [
      {
        "_index": "stof_64312693",
        "_type": "_doc",
        "_id": "1",
        "_score": 0.2876821,
        "_source": {
          "predicates": [
            {
              "suggestion": [
                {
                  "value": "life"
                }
              ]
            }
          ]
        }
      }
    ]