Hi,
I am trying to merge two indexes column wise based on a common key from both the indices. I have tried logstash ruby code, transforms but nothing seems working to me. I am getting individual records having the columns containing either from index1 or index2 but not combined. Please help how i can achieve.
Index1:
{
"_index": "order_details",
"_id": "xxxxxx",
"_version": 1,
"_score": 0,
"_source": {
"amount": 1200,
"shop": "shop_12345",
"@timestamp": "2024-07-17T15:55:46.258578035Z",
"key": "12345678",
"@version": "1",
"source": "AMAZON"
}
},
{
"_index": "order_details",
"_id": "xxxxxx",
"_version": 1,
"_score": 0,
"_source": {
"amount": 500,
"shop": "shop_12345",
"@timestamp": "2024-07-17T15:55:46.258578035Z",
"key": "12345679",
"@version": "1",
"source": "AMAZON"
}
},
{
"_index": "order_details",
"_id": "xxxxxx",
"_version": 1,
"_score": 0,
"_source": {
"amount": 120,
"shop": "shop_12345",
"@timestamp": "2024-07-17T15:55:46.258578035Z",
"key": "12345680",
"@version": "1",
"source": "AMAZON"
}
}
Index2:
{
"_index": "overall_shop",
"_id": "XXXXXXXX",
"_version": 1,
"_score": 0,
"_source": {
"source": "FLIPKART",
"Order Net Value": "2326",
"shop": "shop_12345",
}
}
As i have same filed names in both the indexes fields like shop, source are to be named as shop1, source1 from index1 and shop2, source2 from index2.
Merged index:
{
"_index": "merged_details",
"_id": "xxxxxx",
"_version": 1,
"_score": 0,
"_source": {
"amount": 1200,
"shop1": "shop_12345",
"@timestamp": "2024-07-17T15:55:46.258578035Z",
"key": "12345678",
"@version": "1",
"source1": "AMAZON",
"source2": "FLIPKART",
"Order Net Value": "2326",
"shop2": "shop_12345"
}
},
{
"_index": "merged_details",
"_id": "xxxxxx",
"_version": 1,
"_score": 0,
"_source": {
"amount": 500,
"shop1": "shop_12345",
"@timestamp": "2024-07-17T15:55:46.258578035Z",
"key": "12345679",
"@version": "1",
"source1": "AMAZON",
"source2": "FLIPKART",
"Order Net Value": "2326",
"shop2": "shop_12345"
}
},
{
"_index": "merged_details",
"_id": "xxxxxx",
"_version": 1,
"_score": 0,
"_source": {
"amount": 120,
"shop1": "shop_12345",
"@timestamp": "2024-07-17T15:55:46.258578035Z",
"key": "12345680",
"@version": "1",
"source1": "AMAZON",
"source2": "FLIPKART",
"Order Net Value": "2326",
"shop2": "shop_12345"
}
}