elasticsearch,Ruby,Lucene,elasticsearch" /> elasticsearch,Ruby,Lucene,elasticsearch" />

使用ruby gem的elasticsearch嵌套查询

使用ruby gem的elasticsearch嵌套查询,ruby,lucene,elasticsearch,Ruby,Lucene,elasticsearch,我正在使用elasticsearch ruby gem连接到es服务器,目前有一个带有以下映射的索引。我试图理解查询这些嵌套对象的正确语法。正在尝试以下查询,但不断出现错误。我想知道是否有人能让我开始使用正确的语法来查询这样的结构?谢谢 client = Elasticsearch::Client.new log:true client.search index: 'injuries', nested: { path: { week: {id: '1' } } } 返回: Elasticse

我正在使用elasticsearch ruby gem连接到es服务器,目前有一个带有以下映射的索引。我试图理解查询这些嵌套对象的正确语法。正在尝试以下查询,但不断出现错误。我想知道是否有人能让我开始使用正确的语法来查询这样的结构?谢谢

client = Elasticsearch::Client.new log:true

client.search index: 'injuries', nested: { path: { week: {id: '1' } } }
返回:

Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":"SearchPhaseExecutionException[Failed to execute phase [query
样本映射:

{
  "injuries" : {
    "mappings" : {
      "tbd" : {
        "properties" : {
          "injuries" : {
             "properties" : {
               "timestamp" : {
                 "properties" : {
                   "__content__" : {
                    "type" : "string"
                  },
                   "timeZone" : {
                    "type" : "string"
                  }
                }
              }
            }
          }
        }
      },
      "football" : {
        "properties" : {
          "injuries" : {
            "properties" : {
              "timestamp" : {
                "properties" : {
                  "__content__" : {
                    "type" : "string"
                  },
                  "timeZone" : {
                    "type" : "string"
                  }
                }
              },
              "week" : {
                "properties" : {
                  "id" : {
                    "type" : "string"
                  },
                   "inactivePlayers" : {
                    "properties" : {
                      "inactivePlayer" : {
                        "properties" : {
                          "firstName" : {
                            "type" : "string"
                          },
                          "lastName" : {
                            "type" : "string"
                          },
                          "playerId" : {
                            "type" : "string"
                          },
                          "position" : {
                            "type" : "string"
                          },
                          "status" : {
                            "type" : "string"
                          },
                          "teamId" : {
                            "type" : "string"
                          }
                        }
                      }
                    }
                  },
                  "injuredPlayers" : {
                    "properties" : {
                      "injuredPlayer" : {
                        "properties" : {
                          "displayName" : {
                            "type" : "string"
                          },
                          "firstName" : {
                            "type" : "string"
                          },
                          "gameStatus" : {
                            "type" : "string"
                          },
                          "injury" : {
                            "type" : "string"
                          },
                          "lastName" : {
                             "type" : "string"
                          },
                          "playerId" : {
                            "type" : "string"
                          },
                          "position" : {
                             "type" : "string"
                           },
                           "practiceStatus" : {
                             "type" : "string"
                          },
                          "teamId" : {
                             "type" : "string"
                           }
                        }
                      }
                   }
                  },
                  "season" : {
                     "type" : "string"
                  },
                  "seasonType" : {
                     "type" : "string"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
您的查询似乎没有定义
查询。我认为应该是这样的:

"nested" : {
    "path" : "week",
    "query" : {
        "match" : {"week.id" : "1"}
     }
}