Skip to content

DateMath -- Null string throws exception #1766

Closed
@RobinRieger

Description

@RobinRieger

I am having some problems with the DateRange filter.

The following does not work

string tempField = null;

.DateRange
    (ra => ra.Field(fi => fi.ADate)
        .LessThanOrEquals
            (!string.IsNullOrEmpty(tempField) ? DateTime.UtcNow.ToString() : (string) null))

but this does

.DateRange
    (ra => ra.Field(fi => fi.ADate)
        .LessThanOrEquals
            (!string.IsNullOrEmpty(tempField) ? DateTime.UtcNow : (DateTime?) null))

I have a feeling that the DateMath does not like null values that are 'strings'.

Keeps saying {"Value cannot be null.\r\nParameter name: input"}

From my understanding it should be able to handle this correct? I.e. if it is null then don't send the DateRange stuff to ES.

Edit
I actually get an error with other searchs as well, e.g.

.Query (que =>que.Terms<int>(td => td.Field
    (fi => fi.AField)
    .Terms (null )))

but if I pass a new int[]{} it works.....

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions