c# - Count elements by query in elasticsearch -


i inserted (batch) 616 elements elasticsearch 1.5.1 using nest c# library. see documents using kibana when try counting them nest have got 0 results.

var result = elaticclient.count<bzp>(c => c                 .query(q => q                     .range(r => r                         .onfield(f => f.pubdate)                         .lower(to)                         .greaterorequals(from))                     )             );  return result.count; //result 0 should 616   statuscode: 200,      method: post,      url: http://localhost:9200/_count,      request: {   "query": {     "range": {       "pubdate": {         "gte": "2015-04-29t00:00:00.000",         "lt": "2015-04-30t00:00:00.000"       }     }   } },      response: {"count":0,"_shards":{"total":6,"successful":6,"failed":0}} 

_

 elasticclient.count<bzp>().count //returns correct number of items  

updated: documents have date (pubdate field) april 29th 2015, 00:00:00.000 , imho should count filter.

updated: type registering done nest

 elasticclient.deleteindex("bzp");             elasticclient.createindex("bzp");              idfieldmappingdescriptor desc = new idfieldmappingdescriptor() {   };              elasticclient.map<bzp>(s => s.mapfromattributes()                 .idfield(q=>q.path("id"))                 .timestampfield(z => z.enabled(true).path(q => q.timestamp))); 

and bzp class

public class bzp     {         public datetime timestamp { get; set; }         public string id { get; set; }         public datetime pubdate { get; set; }      } 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -