Thanks @Carlos_D for your response, just one more question regarding your script above -
if (doc.field_name.value != 'undesired_value') --> will it check the value of document which we are trying to ingest or will it check the value of existing document in elastic?
Hi @ashish25 ! It refers to the current document value. There were some errors in the original script I provided - I updated the script in my previous response to properly use ctx._source to refer to the existing document.
In case you want to check the provided value, I would suggest using script parameters for that. Please check these examples.
POST my-test-stream/_doc/123?pipeline=my-pipeline_test
{
"my-keyword-field": "foo",
"status": "Delivered"
}
And after that when I am trying to update above document like:
POST my-test-stream/_update/123?pipeline=my-pipeline_test
{
"my-keyword-field": "foo1",
"status": "Initiate"
}
It is giving me below error instead of dropping the document:
{
"error" : {
"root_cause" : [
{
"type" : "x_content_parse_exception",
"reason" : "[2:3] [UpdateRequest] unknown field [my-keyword-field]"
}
],
"type" : "x_content_parse_exception",
"reason" : "[2:3] [UpdateRequest] unknown field [my-keyword-field]"
},
"status" : 400
}
And also when I am trying to execute below commands, it got updated successfully instead of dropping the document -
POST my-test-stream/_doc/123?pipeline=my-pipeline_test
{
"my-keyword-field": "foo1",
"status": "Initiate"
}
Please let me know whether I am missing something.
I'm able to check the ingested document, but not the existing one on the if section .
Another think I'd like to check is whether it's possible to do that in a script processor, as the context they receive is different that the if section. But I haven't been able to confirm that yet.
Besides that, I can't think of anything else that is Elasticsearch based - it would have to be dealt with at the client level.
script processor is also not able to query existing document
We are having this check at client level but observing some edge scenario where our client is not able to handle it, so trying to explore this option.
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.