Hi,
I haven't been able to find any examples about how to access to a date 
field inside a java native script.
I have a 'datePublished' field defined as following in the mapping:

mappings: { 

   - doc: { 
      - properties: { 
         - ...
         - datePublished: { 
            - format: dateOptionalTime
            - type: date
         }
      }
   }

}

However, inside the class:

public class ScoreByAgeScript extends AbstractDoubleSearchScript {

    public ScoreByAgeScript(@Nullable Map<String,Object> params) {
        ...
    }

    @Override
    public double runAsDouble() {
            Object datePublishedStr = source().get(fieldDate); // => Get a 
string  2013-07-07T12:00:00
            Object datePublishedDoc = doc().get(fieldDate);   //  => Get a 
list of strings [00, 03, 07t12, 2013] 
        }

}

I have been able only to the string text.
I could eventually parse the text to a Date Java object but I would prefer 
to avoid it, avoiding any problem about string format or timezone, etc..
Is there any way to get the java date Object?
Thanks
Niccolo

-- 
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/37cfcecc-400a-4344-95fb-77ab6509520a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to