How do I combine 2 index data in elasticsearch?

It requires writing custom code that uses those APIs.
is there any code snippet that does the operation you mentioned above?