Я пытаюсь получить результат, когда дата окончания проекта меньше текущей даты в группе.
MApping:
{ "supply": {
"properties": {
"rotation_list": {
"type": "nested",
"properties": {
"project_end_date": {
"type": "nested",
"properties": {
"end_date": {
"format": "yyyy-MM-dd",
"type": "date"
}
}
},
"total_days": {
"type": "integer"
}
}
}
}}}
данные
{"rotation_list": [
{
"project_end_date": [
{
"end_date": "2020-08-07"
},
{
"end_date": "2020-07-07"
}
],
"total_days": 23
},
{
"project_end_date": [
{
"end_date": "2020-08-07"
}
],
"total_days": 26
}]}
запрос:
{"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"nested": {
"path": "rotation_list.project_end_date",
"query": {
"script": {
"script": {
"lang": "groovy",
"inline": "def ratable =false;def now_date = new Date();for(i in doc['rotation_list.project_end_date.end_date'].values){def date_check = [];for (j in i){def long_to_str = new Date(j).format('yyyy-MM-dd');def compare_date = Date.parse('yyyy-MM-dd', long_to_str);if (compare_date < now_date) {date_check.add(true);} else {date_check.add(false);}};if (!date_check.contains(false)){ratable = true;break}else{ratable = false}};if(ratable){return true}else {return false}"
}
}
}
}
}
]
}
}
}}}
Я получаю ошибку.
{"type": "missing_method_exception","reason": "No signature of method: static java.util.Date.parse() is applicable for argument types: (java.lang.String, java.lang.Long) values: [yyyy-MM-dd, 1591488000000] Possible solutions: parse(java.lang.String), parse(java.lang.String, java.lang.String), parse(java.lang.String, java.lang.String, java.util.TimeZone), wait(), clone(), grep()"}
Итак, в основном я пытался проверить дату окончания группы каждого раздела проекта меньше текущей даты, а затем только вернуться.