0
votes

Can you do a range query on a string still using nest in the lastest 2.0 alpha release? Or has this been dropped in elasticsearch.

Documentation -- suggests it is still in Elasticsearch itself

however

Range -- seems to only accept 'double'.

E.g.

...
(sh => sh.Range(ra => ra.Field(of =>
    of.Name).LessThanOrEquals(
        !string.IsNullOrEmpty(textInputName)
            ? textInputName.ToString(): null
    ))
...

Used to work in 1.7 Nest, but now says the input for LessThanOrEquals must be a double.

How do I now get everything where 'name' is between, for example, 'a' and 'f'?

Edit:

I think it was removed here in file src/Nest/QueryDsl/TermLevel/Range/RangeQuery.cs... just can not find 'why'.... :S

1
The related issue was github.com/elastic/elasticsearch-net/issues/1611 but it doesn't really mention why either. - Val
Thank you for raising this, it looks like this was removed by accident. I have opened an issue for it github.com/elastic/elasticsearch-net/issues/1728. The Range() method works on numeric fields with a DateRange() method to work on date fields - Russ Cam

1 Answers

0
votes

Range queries on string fields are now in the alpha2 release on nuget

(sh => sh
    .TermRange(ra => ra
        .Field(of => of.Name)
        .LessThanOrEquals(!string.IsNullOrEmpty(textInputName)
            ? textInputName.ToString()
            : null)
)