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

Terms not working as expected #843

Closed
nascosto opened this issue Aug 1, 2014 · 3 comments
Closed

Terms not working as expected #843

nascosto opened this issue Aug 1, 2014 · 3 comments

Comments

@nascosto
Copy link

nascosto commented Aug 1, 2014

I didn't have this problem with pre-1.0.0. I'm attempting to use 1.0.1 right now

I'm having a problem with Terms. It only seems to work for strings. In my case, longs and enums are leaving the filter empty. Also, before I could pass in null to Terms and it would handle it correctly. I can no longer do that. It throws a System.AggregateException in mscorlib.

var query = Query<MyType>.Filtered(filtered => filtered
    .Filter(f =>
        f.Terms(t => t.longValue, new long[] { 1, 2, 3 }) // Produces empty filter
    )
    .Query(q => q.MatchAll())
);
var query = Query<MyType>.Filtered(filtered => filtered
    .Filter(f =>
        f.Terms(t => t.stringValue, new string[] { "test1", "test2", "test3" }) // Working
    )
    .Query(q => q.MatchAll())
);
var query = Query<MyType>.Filtered(filtered => filtered
    .Filter(f =>
        f.Terms(t => t.longValue, new long[] { 1, 2, 3}) && // Produces filter with just the string term filter
        f.Terms(t => t.stringValue, new string[] { "test1", "test2", "test3" }) 
    )
    .Query(q => q.MatchAll())
);
var query = Query<MyType>.Filtered(filtered => filtered
    .Filter(f =>
        f.Terms(t => t.stringValue, (string[]) null) // Boom - Exception thrown
    )
    .Query(q => q.MatchAll())
);

Am I doing something wrong or is this a bug?

@gmarz
Copy link
Contributor

gmarz commented Aug 4, 2014

@nascosto Yea, this definitely looks like a bug. Good catch and thanks for reporting. I'm looking into it now.

gmarz added a commit that referenced this issue Aug 4, 2014
Serialization was being skipped when numeric terms were passed to terms
filter due to incorrect IsConditionless() logic.  This commit also fixes
a NRE that was being thrown when passing a null terms value.  An empty
filter is now created instead.

Closes #843.
@gmarz gmarz added Bug labels Aug 4, 2014
@nascosto
Copy link
Author

nascosto commented Aug 6, 2014

Thanks for fixing this. Looking forward to its release.

@gmarz
Copy link
Contributor

gmarz commented Aug 6, 2014

@nascosto no problem. If you don't want to wait for the 1.0.2 stable release, you can always grab the NuGet package from our CI builds at https://www.myget.org/gallery/elasticsearch-net.

gmarz added a commit that referenced this issue Aug 11, 2014
Serialization was being skipped when numeric terms were passed to terms
filter due to incorrect IsConditionless() logic.  This commit also fixes
a NRE that was being thrown when passing a null terms value.  An empty
filter is now created instead.

Closes #843.
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

2 participants