Hello there,

My question :
When I make a search query of indexed element, i want to parse the result 
of date object value into a Java Object. To make that properly, and because 
I use the Jest API, I need that the Json output format to be in Long, and 
not in the formated String way.
Can I configure the query or the index to get the result in long value (as 
date are stored in long value).

I need to keep the Date Object mapping and not a long one because I use 
some specific aggregation in some query, and it's date, so I want to use 
the date Object...
The problem don't appear when you use date aggregation like date_histogram, 
because in result, you got the key in both formated way (Long and String).

Here an example to detail :

Mapping of the index :
PUT /testindex/test/_mapping
{
  "test": {
            "properties": {
               "date": {
                  "type": "date",
                  "format": "dateOptionalTime"
               }
            }
  }
}

I use the format to put element.

then I do some search query :
GET /testindex/test/_search
{
  "query": {
    "match_all": {}
  }
}

result are this way :
{
   "took": 0,
   ...

   },
   "hits": {
 ...
      "hits": [
         {
            "_index": "testindex",
            "_type": "test",
            "_id": "...",
            "_score": 1,
            "_source": {
               "date": "2014-09-25T11:24:36",
            }
         }
      ]
   }
}

but I want a  date like "date": 1411509600000.
After what I will use Jest or other way to get the value and create a Date 
Java Object with the long value.

For instance :
new 
Date(resultElasticsearch.getJsonObject().get("hits").getAsJsonObject().get("hits").getAsJsonArray().get(0).getAsJsonObject().get("_source").getAsJsonObject().get("date").getAsLong());

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/0ad08992-10e0-46d4-8190-270b95d5c305%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to