Assume I index a field named "created_on" as date type (epoch), now I want to extract reports like
number of documents created on Monday.
2.number of documents created in the month of December.
etc...
now if I simply use date type then these kind of queries are not possible without using scripts but using scripts will make it slower. So it looks like I have to extract these information at the time of indexing and store it as a separate field like created_on_day, created_on_month etc...
I can extract these information at the application level and then index it as separate field altogether but I want to know is it possible to index created_on itself in dfifferent ways (something like this).
e.g...
"properties" : {
"created_on" : {
"type" : "date",
"fields" : {
"day" : {
"type" : "integer",
// is it possible to add some custom analyzer or script to extract the day
}
}
}
}
I tried script processor and it worked for the question I originally posted but I need something generic/reusable.
In actual scenario my index will have lots of date field, like updated_on, closed_on etc..., and if use this script processor then I have to add a three processors for each field, is there any way we can do something generic and use it for all date fields.
You can do everything in a single script processor. Nobody limits you to working with only one field at a time and you don't have to set values to the new fields in separate processors.
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.