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

Source filtering: only accept array items if the previous include pattern matches #22593

Merged
merged 2 commits into from
Jan 13, 2017

Conversation

mikemccand
Copy link
Contributor

Source filtering was incorrectly always accepting array items even if the include pattern did not match.

Closes #22557

…tern matches

Source filtering was always accepting array items even if the include pattern did not match.

Closes elastic#22557
@mikemccand mikemccand added :Core/Infra/Core Core issues without another label >bug v5.2.0 v6.0.0-alpha1 labels Jan 12, 2017
@mikemccand mikemccand self-assigned this Jan 12, 2017
assertThat((Integer) ((List) falteredMap.get("array")).get(0), equalTo(1));
assertThat(((Map<String, Object>) ((List) falteredMap.get("array")).get(1)).size(), equalTo(1));
assertThat((Integer) ((Map<String, Object>) ((List) falteredMap.get("array")).get(1)).get("nested"), equalTo(2));
assertThat(((List) filteredMap.get("array")).size(), equalTo(1));
Copy link
Member

Choose a reason for hiding this comment

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

assertThat((List) filteredMap.get("array"), hasSize(1)) has better error messages.

Copy link
Member

Choose a reason for hiding this comment

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

But you are just fixing a typo so you can skip it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh thank you for that pointer; I didn't know about hasSize ... I'll change it

@mikemccand
Copy link
Contributor Author

OK I switched to hasSize and I also discovered that you can't use that for Map yet ... that's coming in next release of Hamcrest I guess.

@nik9000
Copy link
Member

nik9000 commented Jan 12, 2017

you can't use that for Map yet ... that's coming in next release of Hamcrest I guess.

Oh!

@mikemccand mikemccand merged commit 568e655 into elastic:master Jan 13, 2017
@mikemccand mikemccand deleted the source_include_arrays branch January 13, 2017 00:00
mikemccand pushed a commit that referenced this pull request Jan 13, 2017
…tern matches (#22593)

Source filtering was always accepting array items even if the include pattern did not match.

Closes #22557
mikemccand pushed a commit that referenced this pull request Feb 7, 2017
…tern matches (#22593)

Source filtering was always accepting array items even if the include pattern did not match.

Closes #22557
javanna added a commit that referenced this pull request May 13, 2020
When using source filtering exclusions, empty arrays are not preserved in documents, and no empty arrays are returned if arrays are empty after applying exclusions. We have special treatment to make sure that we preserve empty objects, but the behaviour for arrays is different.

It looks like this regression was introduced by #22593, shortly after we refactored source filtering to use automata (#20736).

Note that this change affects what the search API returns when using source exclusions, as well as what gets indexed when using source exclusions for the _source field.

Closes #23796
javanna added a commit to javanna/elasticsearch that referenced this pull request May 13, 2020
When using source filtering exclusions, empty arrays are not preserved in documents, and no empty arrays are returned if arrays are empty after applying exclusions. We have special treatment to make sure that we preserve empty objects, but the behaviour for arrays is different.

It looks like this regression was introduced by elastic#22593, shortly after we refactored source filtering to use automata (elastic#20736).

Note that this change affects what the search API returns when using source exclusions, as well as what gets indexed when using source exclusions for the _source field.

Closes elastic#23796
javanna added a commit that referenced this pull request May 13, 2020
When using source filtering exclusions, empty arrays are not preserved in documents, and no empty arrays are returned if arrays are empty after applying exclusions. We have special treatment to make sure that we preserve empty objects, but the behaviour for arrays is different.

It looks like this regression was introduced by #22593, shortly after we refactored source filtering to use automata (#20736).

Note that this change affects what the search API returns when using source exclusions, as well as what gets indexed when using source exclusions for the _source field.

Closes #23796
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants