Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison into range query transformation #19

Closed
hoonzis opened this issue Sep 25, 2016 · 1 comment
Closed

Comparison into range query transformation #19

hoonzis opened this issue Sep 25, 2016 · 1 comment

Comments

@hoonzis
Copy link
Owner

hoonzis commented Sep 25, 2016

Currantly any comparison expression is transformed into a Range Query:

sc.FilterOn(x=>` x.Timestamp < DateTime.Now)

will be transformed into:

.DateRange(x => x.LessThan(value).Field("timestamp"));

But if we want to limit the range from both sides currently FluentNest won't be able to smartly used the RangeQuery and will instead create a Bool Query with 2 inside queries. For instance the following:

sc.FilterOn(x=>x.Timestamp < DateTime.Now && x=> x.Timestamp > new DateTime(2015,10,10))

will create something along these lines:

return filterDescriptor.Bool(s => s.Must(leftFilter, rightFilter));

What we should do instead is to apply LessThen and GreaterThan on the range itself.

This will be heuristics optimization inside the recursive parse of the expression tree. It is really not great way to do that. Maybe for FluentNest 2.* we should get a better abstraction of the AST of the expression which could than be optimized, but for now I think I will just implement a quick optim.

@hoonzis
Copy link
Owner Author

hoonzis commented Sep 26, 2016

Fixed with 2.0.196

@hoonzis hoonzis closed this as completed Sep 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant