在 Elastic Search 中搜索并加入两个索引

Search and join two indices in Elastic Search

如何在elasticsearch中匹配查询后加入两个分离的索引?

例如,我有两个名为 all_products 和 SourceTable 的索引。我想根据 product_id

合并两个索引
{
    "_index": "all_products",
    "_type": "all_products",
    "_id": "123",
    "_score": 0.9808292,
    "_source": {
        "city": "CHENNAI",
        "product_id": "123",
        "name": "sam"
    }
},
{
    "_index": "sourcetable",
    "_type": "sourcetable",
    "_id": "232",
    "_score": 0.2876821,
    "_source": {
        "product_id": "123",
        "id": 232
    }
},

Elasticsearch上没有JOIN,但是可以同时搜索同一个字段的两个或多个索引

例如,您可以在字段 product_id 中搜索两个索引中的值 123,但结果不会是联接,它只会 return每个索引有 product_id = 123 的文档。