After provide time format I get; (elastic: Error 400 (Bad Request): all shards failed [type=search_phase_execution_exception] ) error

Please use the following questions as a guideline to help me answer
your issue/question without further inquiry. Thank you.

Which version of Elastic are you using?

[ v] elastic.v7 (for Elasticsearch 7.x)

Please describe the expected behavior

After running following code I get elastic error that : Error 400 (Bad Request): all shards failed [type=search_phase_execution_exception] error;

        dateTime, _ := time.Parse(time.RFC3339, "1553472000")
        f := "yyyy-MM-dd'T'HH:mm:ss"
	concurrentAgg := elastic.NewDateHistogramAggregation().
		Field("date").
		Format(f).
		MinDocCount(0).
		TimeZone("UTC").
		ExtendedBounds(dateTime.Format("2006-01-02 15:04:15"), "now/d").
		OrderByCountDesc()

When I set f as "yyyy-MM-dd HH:mm:ss" everything works as expected.

Please describe the actual behavior

result with no error.

dateTime.Format and time.Parse should be the same format.

        dateTime, _ := time.Parse(time.RFC3339, "1553472000")
        f := "yyyy-MM-dd'T'HH:mm:ss"
	concurrentAgg := elastic.NewDateHistogramAggregation().
		Field("date").
		Format(f).
		MinDocCount(0).
		TimeZone("UTC").
		ExtendedBounds(dateTime.Format("2006-01-02T15:04:15"), "now/d").
		OrderByCountDesc()

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.