es 建立表的时候要将类型设置为 date,也就是设置 mapping
PUT jtthink
{
“mappings”: {
“ipaddr”: {
“properties”: {
“birth”: {
“type”: “date”
}
}
}
}
}
然后插入数据,注意插入数据的格式
PUT /jtthink/ipaddr/11
{
“name”:”zhangfei”,
“age”:33,
“birth”:”2017-09-08T10:10:10″
}
其他相关操作
查看类型
GET jtthink/ipaddr/_mapping
查看数据
GET /jtthink/ipaddr/11
删除数据
DELETE /jtthink/ipaddr/13
Java 的操作
QueryBuilder qb = rangeQuery(“birth”)
.from(“2017-01-01T10:10:01”).to(“2017-12-31T10:10:01”);
SearchResponse sr = client.prepareSearch("jtthink")
.setTypes("ipaddr").setQuery(qb).get();
SearchHit[] result = sr.getHits().getHits();
for(SearchHit searchHit: result){
System.out.println(searchHit.getSourceAsString());
}
作者:shjniu3000
来源:CSDN
原文:https://blog.csdn.net/shjniu3000/article/details/78920318
版权声明:本文为博主原创文章,转载请附上博文链接!