3

I am attempting to query an ES cluster through Nest. However, I'm having an issue because my types are not matching.

This is the C# side:

C#

As you can see CreatedTimeStamp is a DateTime.

However, this is what I receive in Postman:

Postman

Where CreatedTimeStamp is now an Int (or Long).

When I run this basic query:

var searchResponse = Event.client.Search<mdl.Event>(s => s
                    .From(0)
                    .Size(1000)
                    .Query(q => q
                        .MatchAll()));

This is causing the following error:

Elasticsearch.Net.Utf8Json.JsonParsingException : expected:'String Begin Token', actual:'1631555771000', at offset:344

Basically, how can I convert the type from ES to fit the C#?

Benjamin Salerno
  • 107
  • 1
  • 13
  • It looks like the value may be coming through in unix timestamp format. See: https://stackoverflow.com/questions/249760/how-can-i-convert-a-unix-timestamp-to-datetime-and-vice-versa – Jonathan Sep 22 '21 at 20:03
  • Does this answer your question? [How can I convert a Unix timestamp to DateTime and vice versa?](https://stackoverflow.com/questions/249760/how-can-i-convert-a-unix-timestamp-to-datetime-and-vice-versa) – Jonathan Sep 22 '21 at 20:03
  • @Jonathan I understand I can use those functions to convert. I'm more specifically wondering how it can be done in the scope of an Elasticsearch query, if it's possible. – Benjamin Salerno Sep 22 '21 at 20:05

0 Answers0