c# - Getting "An item with this key has already been added" when performing a DeleteByQuery with Nest (Elasticsearch) -
i trying run delete query delete documents between 2 timestamps in index, , getting strange result.
here code:
// how index created if (!es.indexexists(indexname).exists) { es.createindex(descriptor => descriptor .index(indexname) .addmapping<mydocument>(m => m .mapfromattributes())); } // event object mapped public class mydocument { public long id { get; set; } public long eventtime { get; set; } [elasticproperty(index = fieldindexoption.notanalyzed)] public string eventtype { get; set; } public datetime createdat { get; set; } public idictionary<string, object> values { get; set; } // snip } // delete call ielasticclient es; es.deletebyquery<mydocument>(q => q .query(rq => rq .range(t => t.onfield("eventtime").greaterorequals(starttimestamp).lowerorequals(endtimestamp)));
this throws exception saying "an item same key has been added". doing wrong delete query throw exception?
here sample document search did through elasticsearch:
{ "took" : 8, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 96, "max_score" : 1.0, "hits" : [ { "_index" : "testing2", "_type" : "mydocument", "_id" : "112", "_score" : 1.0, "_source":{"id":112,"eventtime":12345690,"eventdate":"1970-05-23t17:21:30-04:00","eventtypeid":0,"ready":false,"name":"","doccount":0,"wordcount":0,"createdat":"2015-06-25t09:29:33.8996707-04:00","values":{"internal_timestamp":76890.0},"childdocuments":[],"parentdocuments":[]} }, /* snip */] } }
rob , worked out.
the problem occurring here project using newtonsoft.json
version 7.0.0
nest version 1.5.1
, whereas nest 1.5.1
requires 6.0.1
. mismatch causing serialization of queries throw exceptions.
this can solved either upgrading nest version 1.6.1
or downgrading newtonsoft.json
version 6.0.1
.
Comments
Post a Comment