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 numerous checks for equality and compatibility in mapper field types #13206

Merged
merged 1 commit into from
Sep 1, 2015

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Aug 31, 2015

The field type tests for mappings had a huge hole: check compatibility
was not tested directly at all! I had meant for this to happen in a
follow up after #8871, and was relying on existing mapping tests.
However, there were a number of issues.

This change reworks the fieldtype tests to be able to check all settable
properties on a field type work with checkCompatibility. It fixes a
handful of small bugs in various field types. In particular, analyzer
comparison was just wrong: it was comparing reference equality for
search analyzer instead of the analyzer name. There was also no check
for search quote analyzer.

closes #13112

The field type tests for mappings had a huge hole: check compatibility
was not tested directly at all! I had meant for this to happen in a
follow up after elastic#8871, and was relying on existing mapping tests.
However, there were a number of issues.

This change reworks the fieldtype tests to be able to check all settable
properties on a field type work with checkCompatibility. It fixes a
handful of small bugs in various field types. In particular, analyzer
comparison was just wrong: it was comparing reference equality for
search analyzer instead of the analyzer name. There was also no check
for search quote analyzer.

closes elastic#13112
@rjernst rjernst added >bug :Search Foundations/Mapping Index mappings, including merging and defining field types v2.0.0 labels Aug 31, 2015
if (!(o instanceof NamedAnalyzer)) return false;
NamedAnalyzer that = (NamedAnalyzer) o;
return Objects.equals(name, that.name);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a better idea, but this makes me slightly nervous since nothing in the API prevents you from doing

Analyzer a1 = new NamedAnalyzer("foo", someAnalyzer);
Analyzer a2 = new NamedAnalyzer("foo", otherAnalyzer);

Copy link
Member Author

Choose a reason for hiding this comment

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

Since an analyzer is essentially code (made up of bundles of other code like tokenizers and token filters), I don't think there is really a way to make them comparable. So I'm not sure there is really anything we can do, the name is the only comparable identifier we have.

@jpountz
Copy link
Contributor

jpountz commented Sep 1, 2015

I left one question about the equality checks but I don't have better ideas... This is good progress compared to what we have in master though so feel free to push even if you don't have ideas how to improve it either.

rjernst added a commit that referenced this pull request Sep 1, 2015
Fix numerous checks for equality and compatibility in mapper field types
@rjernst rjernst merged commit 768bfb7 into elastic:master Sep 1, 2015
@rjernst rjernst deleted the mappings_broken branch September 1, 2015 18:44
@rjernst
Copy link
Member Author

rjernst commented Sep 2, 2015

I will backport this to 2.0 as well, but am waiting on the backport of some geo changes that will make the backport clean.

rjernst added a commit that referenced this pull request Sep 8, 2015
Fix numerous checks for equality and compatibility in mapper field types
@rjernst rjernst added the v2.0.0 label Sep 8, 2015
@rjernst
Copy link
Member Author

rjernst commented Sep 8, 2015

Here is the 2.0 commit: 9e10e88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker >bug :Search Foundations/Mapping Index mappings, including merging and defining field types v2.0.0-beta2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IP fields cause mapping conflicts
3 participants