我需要在单个请求中通过其他类型的外部id进行搜索。 我可以这样做吗?
例如: 单索引中有两种类型。 1.矩阵 - 包含名称和对象中的几个products_id
root@401488a854ac:/usr/share/elasticsearch# curl 'localhost:9200/ta/products/1?pretty'
{
"_index" : "ta",
"_type" : "products",
"_id" : "1",
"_version" : 1100,
"found" : true,
"_source" : {
"@timestamp" : "2016-12-21T11:08:00.443Z",
"componentsNested" : [
{
"amount" : 992,
"component_id" : 92
},
{
"amount" : 162,
"component_id" : 35
},
{
"amount" : 551,
"component_id" : 57
},
{
"amount" : 96,
"component_id" : 28
},
{
"amount" : 520,
"component_id" : 92
},
{
"amount" : 834,
"component_id" : 75
},
{
"amount" : 265,
"component_id" : 87
},
{
"amount" : 520,
"component_id" : 86
},
{
"amount" : 558,
"component_id" : 12
},
{
"amount" : 426,
"component_id" : 19
},
{
"amount" : 22,
"component_id" : 6
},
{
"amount" : 955,
"component_id" : 79
},
{
"amount" : 93,
"component_id" : 50
},
{
"amount" : 113,
"component_id" : 99
},
{
"amount" : 617,
"component_id" : 53
},
{
"amount" : 542,
"component_id" : 64
}
],
"name" : "eveniet",
"@version" : "1",
"id" : 1,
"type" : "products",
"tags" : [ ]
}
}
root@401488a854ac:/usr/share/elasticsearch# curl 'localhost:9200/ta/matrix/1?pretty'
{
"_index" : "ta",
"_type" : "matrix",
"_id" : "1",
"_version" : 1101,
"found" : true,
"_source" : {
"productsNested" : [
{
"cost" : 643,
"product_id" : 62
},
{
"cost" : 599,
"product_id" : 13
},
{
"cost" : 268,
"product_id" : 22
},
{
"cost" : 638,
"product_id" : 73
},
{
"cost" : 782,
"product_id" : 94
},
{
"cost" : 84,
"product_id" : 46
},
{
"cost" : 170,
"product_id" : 49
},
{
"cost" : 172,
"product_id" : 16
},
{
"cost" : 765,
"product_id" : 36
},
{
"cost" : 386,
"product_id" : 85
},
{
"cost" : 896,
"product_id" : 62
},
{
"cost" : 248,
"product_id" : 71
},
{
"cost" : 267,
"product_id" : 48
},
{
"cost" : 40,
"product_id" : 90
},
{
"cost" : 506,
"product_id" : 63
},
{
"cost" : 307,
"product_id" : 15
},
{
"cost" : 731,
"product_id" : 74
},
{
"cost" : 23,
"product_id" : 71
},
{
"cost" : 214,
"product_id" : 93
},
{
"cost" : 316,
"product_id" : 48
},
{
"cost" : 449,
"product_id" : 100
},
{
"cost" : 413,
"product_id" : 30
},
{
"cost" : 476,
"product_id" : 91
},
{
"cost" : 482,
"product_id" : 73
},
{
"cost" : 238,
"product_id" : 19
},
{
"cost" : 75,
"product_id" : 21
},
{
"cost" : 712,
"product_id" : 32
},
{
"cost" : 577,
"product_id" : 8
}
],
"@timestamp" : "2016-12-21T11:09:00.251Z",
"@version" : "1",
"id" : 1,
"type" : "matrix",
"tags" : [ ]
}
}
我可以毫无问题地搜索它。
curl -XPOST' localhost:9200 / ta / products,matrix / _search?pretty' -d' { "查询" :{" terms":{ " _type":["产品","矩阵" ]}}, " aggs":{ "类型":{ "条款":{ " field":" _type", "尺寸":10 }," aggs" :{" ids" :{ "术语#34; :{ " field":" id" }}} '
结果正确。 我如何通过矩阵名查询product_ids并在单个请求中查找此文档?