Hi everybody,
My table columns are not always null! Therefore, I need to check when querying the date range.
I'm passing the Linq question below. How can I do that?
query = query.where(p =>
(!p.markasnewstartdatetimeutc.hasvalue || p.markasnewstartdatetimeutc.value < nowutc) &&
(!p.markasnewenddatetimeutc.hasvalue || p.markasnewenddatetimeutc.value > nowutc));
Sample Usage!
List<Func<QueryContainerDescriptor<Product>, QueryContainer>>();
var nowUtc = DateTime.UtcNow;
if (markedAsNewOnly)
{
filters.Add(fq => fq.Terms(t => t.Field(f => f.MarkAsNew).Terms(true)));
filters.Add(fq => fq.Exists())
filters.Add(fq => fq.DateRange(dr =>
{
//?????
}));
}
var searchResponse = client.Search<Product>(s => s
.Index("product")
.Query(q => q.Bool(b => b.Filter(filters)))
);