NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Date Range Query Usageedit
Fluent DSL exampleedit
q .DateRange(c => c .Name("named_query") .Boost(1.1) .Field(p => p.LastActivity) .GreaterThanOrEquals(DateMath.Now.Subtract("1y").RoundTo(DateMathTimeUnit.Month)) .LessThanOrEquals(DateMath.Now) .Format("dd/MM/yyyy||yyyy") .TimeZone("+01:00") )
Object Initializer syntax exampleedit
new DateRangeQuery { Name = "named_query", Boost = 1.1, Field = "lastActivity", GreaterThanOrEqualTo = DateMath.Now.Subtract("1y").RoundTo(DateMathTimeUnit.Month), LessThanOrEqualTo = DateMath.Now, TimeZone = "+01:00", Format = "dd/MM/yyyy||yyyy" }
Example json output.
{ "range": { "lastActivity": { "_name": "named_query", "boost": 1.1, "format": "dd/MM/yyyy||yyyy", "gte": "now-1y/M", "lte": "now", "time_zone": "+01:00" } } }