Have a look at transforms, you can source both indexes, use a pivot, group on terms using the field id. For the output fields you have several options (just ideas, not verified):
a filter aggregation and top_metrics as sub aggregation
top_metrics on top, sort by _index ascending for index 1, descending to get index 2
Your call does not look correct to me, can you delete the id from the body and don't use the underscore in the path?
PUT _transform/index_merge
{
...
}
The id (index_merge) must be specified as part of the path. You can specify it in the body, too, but than they must match. Leading underscores are not allowed.
Can you provide the version and environment you are using? It seems like you are either using a version that does not provide transform or you lack permissions.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.