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

Using a single 'Range' query inside a Query can cause a server side error #971

Closed
kohner86 opened this issue Sep 30, 2014 · 7 comments
Closed

Comments

@kohner86
Copy link

Not sure if this is by design but if I define a query with a single QueryDescriptor inside of type Range in which the 'OnField' value is null ES throws a QueryParsingException since the emitted JSON in the query is empty due to no queries being present.

It seems that the nest library will automatically inject a match_all into the query if none are specified but in the above case the match_all is not added.

In the mean time I've been able to stop the issue from popping up by putting the Range query in a boolean query paired with a match_all.

@gmarz
Copy link
Contributor

gmarz commented Sep 30, 2014

@kohner86 would you mind posting your code or an example which produces this error?

@kohner86
Copy link
Author

Sure,
Here is a snippet which generates the error when minDate and maxDate are both null:
ISearchResponse authorStats = await esClient.SearchAsync(s =>
s.Take(0)
.Query(h =>
h.Filtered(w =>
w.Filter(f =>
f.Term(g => g.FeedId, feedId))
.Query(r =>
r.Range(x => x
.OnField(d => d.Service.Created)
.GreaterOrEquals(minDate)
.LowerOrEquals(maxDate)))))
.SortDescending(z => z.Service.Created)
.Take(_numToTake));

Which generates the following error:
nested: QueryParsingException[[default1] [_na] query malformed, no field after start_object]; }

@gmarz gmarz closed this as completed in 147dbb5 Oct 1, 2014
@gmarz gmarz added the Bug label Oct 1, 2014
@gmarz
Copy link
Contributor

gmarz commented Oct 1, 2014

@kohner86

This was a bug with FilteredQuery, and not Range. I just pushed the above fix. Thanks for reporting this!

@BjBlazkowicz
Copy link

I'm also getting errors with the RangeQueryDescriptor when using OnField:

        var result = _client.Search<Movie>(
            x => x.Query(q => q
                .Range(
                    r => r
                        .GreaterOrEquals(DateTime.Now.AddSeconds(-secondsBack))
                        .OnField(f => f.LastSeen)
                        ))
                .From(from)
                .Take(take)
                .SortDescending(s => s.Viewers));

@gmarz
Copy link
Contributor

gmarz commented Dec 12, 2014

@BjBlazkowicz What is the error you're getting?

@BjBlazkowicz
Copy link

Sorry gmarz, no exceptions and errors. My bad.

But I think we should be able to set the timezone in the Range query?

@gmarz
Copy link
Contributor

gmarz commented Dec 16, 2014

@BjBlazkowicz sorry this fell under my radar since the issue was closed. Yup, you are totally right, time_zone was just added in ES 1.4. I opened #1158.

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

3 participants