2
我的映射(的一部分):Elasticsearch。嵌套查询嵌套在嵌套
$index = [
"mappings" => [
"goods" => [
"dynamic_templates"=> [
[
"iattribute_id"=> [
"match_mapping_type"=> "string",
"match"=> "attribute_id",
"mapping"=> [
"type"=> "integer"
]
]
],
[
"iattribute_value"=> [
"match_mapping_type"=> "string",
"match"=> "attribute_value",
"mapping"=> [
"type"=> "string",
"index" => "not_analyzed"
]
]
]
],
"properties" => [
...
"individual_attributes" => [
"type" => "nested",
"properties" => [
"template_id" => ["type" => "integer"],
"attributes_set" => [
"type" => "nested",
"properties" => [
"attribute_id" => ["type" => "integer"],
"attribute_value" => ["type" => "string", "index" => "not_analyzed"]
]
]
]
]
...
]
]
]
];
我如何可以查询attribute_id
和attribute_value
?它们嵌套在嵌套内部。我无法理解如何指定字段的路径。 我编写了查询,但它不起作用。
GET /index/type/_search
{
"query" : {
"nested" : {
"path" : "individual_attributes.attributes_set",
"score_mode" : "none",
"filter": {
"bool": {
"must": [
{
"term" : {
"individual_attributes.attributes_set.attribute_id": "20"
}
},
{
"term" : {
"individual_attributes.attributes_set.attribute_value": "commodi"
}
}
]
}
}
}
}
}
它不工作...莫比有毛病我映射。 GET/index/_mapping/type为我提供了以下内容 - laravel.io/bin/8KW8v –
如果这是您的映射,则索引中存在更严重的问题。根据您在php中的映射,映射不包含'nested'字段。因此,索引不是创建的,你认为它是在你的php代码中,或者该映射属于不同的索引。 –
我无法查看映射(laravel.io/bin/fork/yGvY6),除非我在github中给予我的私人电子邮件地址的读取权限。我不打算这样做。但是,正如我所说的,我在** laravel.io/bin/8KW8v **中看到的映射与您在php代码中的映射不匹配。没有什么可以补充的。您需要修复您的映射,以便这些字段是嵌套的。然后我建议的查询将起作用。 –