Hi,
Is _timeStamp a kind of hidden field ? Why is this field not displayed in
the result (see hereafter response result) ?
Code
XContentBuilder mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("time-type")
.startObject("_timestamp")
.field("enabled", true)
.field("store", "yes")
.endObject()
.endObject()
.endObject();
client.admin().indices().prepareCreate("timestamp-id")
.addMapping("time-type", mapping)
.execute().actionGet();
client.prepareIndex("timestamp-id", "time-type", "1")
.setSource("field1", "value1")
.setTimestamp("2013-01-01T00:00:00")
.setRefresh(true).execute().actionGet();
requestBuilder = client.prepareSearch("timestamp-id")
.setQuery(QueryBuilders.rangeQuery("_timestamp").gte("2012-01-01").lte("2014-01-01"));
response = requestBuilder.execute().actionGet();
Query :
{
"query" : {
"range" : {
"_timestamp" : {
"from" : "2012-01-01",
"to" : "2014-01-01",
"include_lower" : true,
"include_upper" : true
}
}
}
}
Response
Search result 1 : {
"took" : 17,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "timestamp-id",
"_type" : "time-type",
"_id" : "1",
"_score" : 1.0, "_source" : {"field1":"value1"}
} ]
}
}
Regards,
Charles
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.