DateRange if DateTime Field not null?

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)))
            );

help me!

Read this and specifically the "Also be patient" part.

I am still waiting, it is very difficult!

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