Re: Accessing date field in a native (Java) script

2014-03-31 Thread Niccolò Becchi
Sorry Bihn,
just seen now your suggestion but It doesn't work.
For a field* datePublished: {format: dateOptionalTime, type: date}* when 
I perform:

ScriptDocValues v = (ScriptDocValues) doc().get(dateField);

I got an object 
org.elasticsearch.index.fielddata.ScriptDocValues$Strings@5e834b36 that's 
containing the following strings:

[01, 12, 15z, 2014, 30t10]

For the following date 2014-01-30T10:12:15Z stored in ES. I don't know how 
to fix it.
Thanks a lot
Niccolo'


Il giorno lunedì 10 marzo 2014 18:22:23 UTC, Binh Ly ha scritto:

 If you do something like this, you should get the epoch value in 
 milliseconds. Then you can use that value to initialize whatever object you 
 want:

   ScriptDocValues v = (ScriptDocValues) doc().get(dateField);
   if (v != null  !v.isEmpty()) {
 long epoch_ms = ((Longs)v).getValue();
   }



-- 
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/deb72f15-f765-4287-b073-b9ddce1ef7fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing date field in a native (Java) script

2014-03-10 Thread Binh Ly
If you do something like this, you should get the epoch value in 
milliseconds. Then you can use that value to initialize whatever object you 
want:

  ScriptDocValues v = (ScriptDocValues) doc().get(dateField);
  if (v != null  !v.isEmpty()) {
long epoch_ms = ((Longs)v).getValue();
  }

-- 
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/f746d44b-f9dd-4c65-a4af-f653fb8e86c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.