POST test-transaction/_update/2
{
"scripted_upsert": true,
"script": {
"source": """
// Fetch the document from the other index
def txnDoc = ctx._source;
def status = txnDoc['status'];
def evtDoc = ctx._index['test-event'].get('3');
A script only has access to the current document and can not lookup documents in other indices. The only way you may be able to do this would be through an ingest pipeline with an enrich processor.
Am I correctly understanding that you want an exect term match on the correlationId but only consider documents that have the eventStatus field set to "Delivered"?
I do not think the API allows this (am not sure though), but you might want to add an alias with a filter clause on top of your indices and see if you can run the enrich policy based on this instead of directly linking to the indices. Have never done this so am not sure it will work.
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.