今天使用javaAPI对elasticsearch写按时间范围查询的时候,一直报NumberFormatException,查了很多方法都无用,自己尝试了很多方法都没用,最后选择不传时间,改传毫秒时间戳,完美解决问题。
Calendar targetDate = cal;
targetDate.add(Calendar.YEAR, -1);
Long targetDate1 = targetDate.getTimeInMillis();
s = QueryBuilders.rangeQuery("publishTime").from(targetDate1).to(today1);
本文分享了一次使用Java API进行Elasticsearch时间范围查询遇到NumberFormatException错误的解决经验,通过将时间转换为毫秒时间戳成功避免了该问题。
725

被折叠的 条评论
为什么被折叠?



