Hello Michael ,

Please find the answers in the order of questions you have asked -


   1. Referencing script from file system is explained here. It has very
   well worked for me , please double check on it -
   
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html
   2. I feel you haven't declared that field as date type in the schema .
   If you had done that , you will recieve the epoch instead of string. -
   
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#date
   3. Dates are internally stored as epoch. So it should handle that second
   fraction too. More on the format can be seen here -
   
http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html
   4. What exactly do you want to do with the duration ? If its range
   aggregation , it does have script support -
   
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html#search-aggregations-bucket-range-aggregation

Thanks
          Vineeth

On Wed, Sep 10, 2014 at 11:32 AM, Michael Giagnocavo <m...@giagnocavo.net>
wrote:

> I'm trying to work with dates inside a script. I've got a few questions:
>
> 1. How do I reference a script that I have in the scripts directory?
> Simply POSTing to /index/type/id/_update with { "script": "scriptname" }
> does not seem to work. "No such property: scriptname for class: ScriptN",
> where N starts at 3 (I have two .groovy files in my scripts directory).
>
> 2: How can I get actual date objects from the source?
> ctx._source.fieldname always returns a type string, even if I just created
> the field with ctx._source.fieldname = new Date(). Right now I'm parsing
> the string output in Groovy, which seems suboptimal.
>
> 3: Are ISO8601 dates not fully supported, as far as arbitrary fractional
> second decimals? (Not just 3 or another fixed number?) Any suggestions on
> handling JSON input from multiple sources, some of which have
> high-precision?
>
> 4: Can I use a script to project the document into a scalar for
> aggregates? For instance, if I have Date fields "start" and "end", and want
> to calculate the average duration (start - end) in an aggregate. I see
> value-level scripts are allowed, and 1.4 has "scripted metric aggregation".
> For now am I best off just storing the duration in the document?
>
> Thank you,
> Michael
>
> --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elasticsearch+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/13d4cf783a83447a84b62206605ad312%40CO1PR07MB331.namprd07.prod.outlook.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3DBzthM14yz3SuzxvTz5QXOW4Gtt72rvsA1-dND5eP--A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to