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

Fix NPE during search with source filtering if the source is disabled. #20093

Merged

Conversation

qwerty4030
Copy link
Contributor

@qwerty4030 qwerty4030 commented Aug 20, 2016

Fix NPE during search with source filtering if the source is disabled.
Instead of throwing an NPE, search response hits with source filtering will not contain the source if it is disabled in the mapping.

Tests pass: gradle test gradle core:integTest

Closes #7758

Instead of throwing an NPE, a search response with source filtering will not contain the source if it is disabled in the mapping.

Closes elastic#7758
@s1monw
Copy link
Contributor

s1monw commented Aug 22, 2016

I mean the code LGTM but I wonder if we can start adding a unittest instead of an integration test for this?

@clintongormley clintongormley added >bug :Search/Search Search-related issues that do not fall into other categories labels Aug 22, 2016
…tchingIT.

Removed SourceFetchingIT#testSourceDisabled (now covered via unit test FetchSourceSubPhaseTests#testSourceDisabled).
}
}

public void test() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename this testBasicOperation or something?

@qwerty4030
Copy link
Contributor Author

@s1monw added unit tests. reverted integration test for disabled source.
The unit tests cover the disabled source scenario as well as the existing integration tests. Should we remove some of the other integration tests? Also I didn't get into randomized testing, complex doc sources, etc... I think these should be covered by XContentMapValuesTests (tests the actual filter logic).

@nik9000
Copy link
Member

nik9000 commented Aug 26, 2016

Looks good to me. I left a few style comments if you are interested in them, otherwise I can test locally and merge.

Renamed main unit test method.
Use assertEquals and assertNull instead of assertThat (less code).
@s1monw
Copy link
Contributor

s1monw commented Aug 26, 2016

test this please

@nik9000
Copy link
Member

nik9000 commented Aug 26, 2016

Awesome. @s1monw's kicked off a CI build for this.

@nik9000
Copy link
Member

nik9000 commented Aug 26, 2016

@elasticmachine, test this please.

@nik9000 nik9000 merged commit 9172653 into elastic:master Aug 27, 2016
@nik9000
Copy link
Member

nik9000 commented Aug 27, 2016

@qwerty4030, tests passed last night so I've merged. Thanks for fixing this!

@qwerty4030 qwerty4030 deleted the fix/7758_search_source_filtering_disabled branch August 27, 2016 22:09
javanna added a commit to javanna/elasticsearch that referenced this pull request Sep 12, 2016
…xclude and source is disabled in the mappings. Fixing meant ignoring the _source parameter in the request as no fields can be extracted from it.

We should rather throw a clear exception to clearly point out that we cannot extract fields from _source. Note that this happens only when explicitly trying to extract fields from source. When source is disabled and no _source parameter is specified, no errors will be thrown and no source will be returned.

Closes elastic#20408
Relates to elastic#20093
javanna added a commit that referenced this pull request Sep 12, 2016
…and source is disabled in the mappings. Fixing meant ignoring the _source parameter in the request as no fields can be extracted from it.

We should rather throw a clear exception to clearly point out that we cannot extract fields from _source. Note that this happens only when explicitly trying to extract fields from source. When source is disabled and no _source parameter is specified, no errors will be thrown and no source will be returned.

Closes #20408
Relates to #20093
javanna added a commit that referenced this pull request Sep 12, 2016
…and source is disabled in the mappings. Fixing meant ignoring the _source parameter in the request as no fields can be extracted from it.

We should rather throw a clear exception to clearly point out that we cannot extract fields from _source. Note that this happens only when explicitly trying to extract fields from source. When source is disabled and no _source parameter is specified, no errors will be thrown and no source will be returned.

Closes #20408
Relates to #20093
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories v5.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants