Hello,
i need to add a field to check whether the date field is weekend or not.
I found below script for weekend identification.
doc[alrm_occr_ddt'].date.dayOfWeek == 6 || doc[alrm_occr_ddt'].date.dayOfWeek == 7"
so i tries to put ingest pipelines as below.
PUT _ingest/pipeline/weekend_true
{
"processors" : [
{
"set": {
"field": "weekend",
"value": "true"
}
}
]
}
PUT _ingest/pipeline/addWeek
{
"description": "check weekend by using alrm_occr_ddt.date.dayOfWeek",
"version": 1,
"processors": [
{
"pipeline": {
"if": "doc[alrm_occr_ddt'].date.dayOfWeek == 6 || doc[alrm_occr_ddt'].date.dayOfWeek == 7",
"name": "weekend_false"
}
}
]
}
but i am experiencing below error when i tried to put a test index.
PUT test1/doc/2?pipeline=addWeek
{
"alrm_occr_ddt" : "2019-04-15T02:03:14.000Z"
}
#ERROR
{
"error": {
"root_cause": [
{
"type": "exception",
"reason": "java.lang.IllegalArgumentException: ScriptException[compile error]; nested: IllegalArgumentException[unexpected character ['].date.dayOfWeek == 2].]; nested: LexerNoViableAltException;",
"header": {
"processor_type": "conditional"
}
}
],
"type": "exception",
"reason": "java.lang.IllegalArgumentException: ScriptException[compile error]; nested: IllegalArgumentException[unexpected character ['].date.dayOfWeek == 2].]; nested: LexerNoViableAltException;",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "ScriptException[compile error]; nested: IllegalArgumentException[unexpected character ['].date.dayOfWeek == 2].]; nested: LexerNoViableAltException;",
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"doc[alrm_occr_ddt'].date.dayOfWeek == 2",
" ^---- HERE"
],
"script": "doc[alrm_occr_ddt'].date.dayOfWeek == 2",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "unexpected character ['].date.dayOfWeek == 2].",
"caused_by": {
"type": "lexer_no_viable_alt_exception",
"reason": null
}
}
}
},
"header": {
"processor_type": "conditional"
}
},
"status": 500
}
can anyone please advise how i can avoid the error and put correct weekend info?
thank you!