date - Elasticsearch NumberFormatException when running two consecutive java tests -


i have 2 test in class, each of them containing following query:

searchquery searchquery = new nativesearchquerybuilder().withquery(matchallquery()).withfilter(rangefilter("publishdate").lt(date)).build(); 

in 1 of tests, number of results elasticsearchtemplate.count(searchquery, article.class), in other 1 returned values verified elasticsearchtemplate.queryforpage(searchquery,article.class)

if run of these 2 tests separately, tests pass, seems work perfectly. if run both of 2 tests consequently, 1 after other, the first 1 passes, other 1 fails searchphaseexecutionexception: failed execute phase ... nested: numberformatexception[for input string: "2015-02-01t00:02:02.396z"]...

it's more strange, behavior appears when rangefilter publishdate (having type: fieldtype.date) applied. when other similar queries boolfilter, termfilter etc applied consequently, tests pass.

also, if run these 2 queries inside same method: no exception thrown.

i thought improper cache initialization/cleanup might cause behavior... still, why not happen other queries well?

also, in @after method of class delete indexes (elasticsearchtemplate.deleteindex(article.class)), , in @before method do/redo bulk indexing , refresh.

am on wrong path? missing here?

the full stack trace:

org.elasticsearch.action.search.searchphaseexecutionexception: failed execute phase [dfs], shards failed; shardfailures {[jcbspj2yr3qkx6hxn_xr4w][articles][0]: searchparseexception[[articles][0]: query[constantscore(*:*)],from[0],size[10]: parse failure [failed parse source [{"from":0,"size":10,"query":{"match_all":{}},"post_filter":{"range":{"publishdate":{"from":null,"to":"2015-02-01t00:02:02.676z","include_lower":true,"include_upper":false}}}}]]]; nested: numberformatexception[for input string: "2015-02-01t00:02:02.676z"]; }{[jcbspj2yr3qkx6hxn_xr4w][articles][1]: searchparseexception[[articles][1]: query[constantscore(*:*)],from[0],size[10]: parse failure [failed parse source [{"from":0,"size":10,"query":{"match_all":{}},"post_filter":{"range":{"publishdate":{"from":null,"to":"2015-02-01t00:02:02.676z","include_lower":true,"include_upper":false}}}}]]]; nested: numberformatexception[for input string: "2015-02-01t00:02:02.676z"]; }{[jcbspj2yr3qkx6hxn_xr4w][articles][2]: searchparseexception[[articles][2]: query[constantscore(*:*)],from[0],size[10]: parse failure [failed parse source [{"from":0,"size":10,"query":{"match_all":{}},"post_filter":{"range":{"publishdate":{"from":null,"to":"2015-02-01t00:02:02.676z","include_lower":true,"include_upper":false}}}}]]]; nested: numberformatexception[for input string: "2015-02-01t00:02:02.676z"]; }{[jcbspj2yr3qkx6hxn_xr4w][articles][3]: searchparseexception[[articles][3]: query[constantscore(*:*)],from[0],size[10]: parse failure [failed parse source [{"from":0,"size":10,"query":{"match_all":{}},"post_filter":{"range":{"publishdate":{"from":null,"to":"2015-02-01t00:02:02.676z","include_lower":true,"include_upper":false}}}}]]]; nested: numberformatexception[for input string: "2015-02-01t00:02:02.676z"]; }{[jcbspj2yr3qkx6hxn_xr4w][articles][4]: searchparseexception[[articles][4]: query[constantscore(*:*)],from[0],size[10]: parse failure [failed parse source [{"from":0,"size":10,"query":{"match_all":{}},"post_filter":{"range":{"publishdate":{"from":null,"to":"2015-02-01t00:02:02.676z","include_lower":true,"include_upper":false}}}}]]]; nested: numberformatexception[for input string: "2015-02-01t00:02:02.676z"]; } @ org.elasticsearch.action.search.type.transportsearchtypeaction$baseasyncaction.onfirstphaseresult(transportsearchtypeaction.java:238) @ org.elasticsearch.action.search.type.transportsearchtypeaction$baseasyncaction$1.onfailure(transportsearchtypeaction.java:184) @ org.elasticsearch.search.action.searchservicetransportaction$23.run(searchservicetransportaction.java:565) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:722) 

the mapping article index:

@document(indexname = "articles", type = "article", shards = 1, replicas = 0, refreshinterval = "-1", indexstoretype = "memory") public class article { @id private long id; @field(type = fieldtype.string, store = true) private string title; @field(type = fieldtype.string, store = true) private string text; @field(type = fieldtype.string, store = true) private string author; @field(type = fieldtype.date, store = true) private date publishdate; @field(type = fieldtype.date, store = true) private date lastmodificationdate; .... } 

since exception complains numberformatexception, should try sending date long (instead of date object) since how dates stored internally. see i'm calling date.gettime() in code below:

searchquery searchquery = new nativesearchquerybuilder()     .withquery(matchallquery())     .withfilter(rangefilter("publishdate").lt(date.gettime())).build(); 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -