In an index, I have a field called date (format: YYYY-MM-DD HH:MM:SS)
How can I create a new field "called Date3M) to have the same date but 3 months ago ?
Example: Date: 2016-07-05 02:30:54
Date3M: 2016-04-05 2:30:54
Thanks!
In an index, I have a field called date (format: YYYY-MM-DD HH:MM:SS)
How can I create a new field "called Date3M) to have the same date but 3 months ago ?
Example: Date: 2016-07-05 02:30:54
Date3M: 2016-04-05 2:30:54
Thanks!
If you need to store the field I think you have to use any kind of scripting.
there is no other solution with Lucene ?
I don't think so, maybe someone else have any ideas...?
What do you want to achive? You probably can do the date math in your injection pipeline...
In this case you can use script field in your query
"script_fields" : { "myField" : { "script" : "doc['my_field_name'].value * 2" } }
Where you can define what should happen, let's say that you storing date in timestamp then you can do this:
"script_fields" : {
"date3m" : {
"script" : "doc['date'].value - 32460*60"
}
}
© 2020. All Rights Reserved - Elasticsearch
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.