-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
I've a unit test where I'm able to repro the problem, I explicitly set Italian culture with a dot as separator for DateTimeFormat.TimeSeparator
var cultureInfo = new CultureInfo("IT-it");
cultureInfo.DateTimeFormat.DateSeparator = ".";
cultureInfo.DateTimeFormat.TimeSeparator = ".";
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
//I issue the query hereThe query fails with an exception
ElasticsearchParseException[failed to parse date field [2015-01-30T08.52.32.443], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2015-01-30T08.52.32.443" is malformed at ".32.443"]
I Elastic Search needs semicolon to separate hours, minutes and milliseconds, and rejects the query. When a DateTime is converted to string, localization should not be considered.
Actually I've patched my code using string instead of DateTime in Nest query.
public const String DateTimeFormatForNestQuery = "yyyy-MM-ddThh:mm:ss.fff";
...
String startValueFormatted = startValue.ToString(DateTimeFormatForNestQuery, CultureInfo.InvariantCulture);
String endValueFormatted = endValue.ToString(DateTimeFormatForNestQuery, CultureInfo.InvariantCulture);
.OnField(d => d.PublishDate)
.GreaterOrEquals(startValueFormatted)
.LowerOrEquals(endValueFormatted))); Metadata
Metadata
Assignees
Labels
No labels