Skip to content

Parse and validate mappings on index template creation #8802

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

Merged
merged 1 commit into from
Jun 1, 2016

Conversation

johtani
Copy link
Contributor

@johtani johtani commented Dec 6, 2014

Parse and validate mappings in template when it puts.

  • parse and validate mappings in template using dummy index service
  • return error if template include invalid mapping
  • Not support a partial template

Close #2415

client().admin().indices().preparePutTemplate("template_1")
.setTemplate("*")
.setSettings(
" {\n" +
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: align this line with the strings below?

@rjernst
Copy link
Member

rjernst commented Dec 8, 2014

@johtani I left some comments.

@imotov
Copy link
Contributor

imotov commented Apr 25, 2015

Any news on this one? I just ran into the situation that testBrokenMapping test generates. Basically after a broken template like in the test is added to the cluster the global cluster state becomes unserializable, which means curl localhost:9200/_cluster/state fails and any future changes into global cluster state (such as templates, repositories, persistent settings, etc) are no longer persisted.

@clintongormley
Copy link
Contributor

@rjernst does this issue become any easier with the changes you've made to mappings?

@rjernst
Copy link
Member

rjernst commented Jul 18, 2015

Unfortunately not. Until mapping parsing is completely isolated from binding to a particular index (eg keeping an analyzer name, instead of looking up an actual analyzer and storing that), we will not be able to do this cleanly. Note that eventually this should be possible, as we move towards immutable mappings.

However, IIRC, this PR was done by creating a temporary index, which we already do in at least one other place. As long as we are careful with deleting the index (my last comments on this PR), I think this can work as an intermediate solution.

@jpountz jpountz self-assigned this May 25, 2016
}
}

public void merge(Map<String, Map<String, Object>> mappings, boolean updateAllTypes) throws MapperParsingException {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you leave a "TODO: make this atomic"?

@jpountz
Copy link
Contributor

jpountz commented May 25, 2016

I left some comments but other than that it looks good to me now!

@johtani johtani force-pushed the fix/validate_index_template branch 2 times, most recently from 3230543 to 1a5c253 Compare May 31, 2016 07:10
@johtani
Copy link
Contributor Author

johtani commented May 31, 2016

@jpountz I rebased and fixed your comment. Could you review again?

@jpountz
Copy link
Contributor

jpountz commented May 31, 2016

LGTM

… puts

Share applying template with MetaDataCreateIndexService and MetaDataIndexTemplateService
Add some unit test
Collapse addMappingsToMapperService and move it to MapperService
Extract validateTemplate method
use expectThrows in testcase
Add TODO comment

Closes elastic#2415
@johtani johtani force-pushed the fix/validate_index_template branch from 1a5c253 to fd76291 Compare June 1, 2016 08:47
@johtani johtani merged commit fd76291 into elastic:master Jun 1, 2016
@clintongormley clintongormley changed the title Index Template: Parse and validate mappings in template when it puts Parse and validate mappings on index template creation Jun 1, 2016
@johtani
Copy link
Contributor Author

johtani commented Jun 9, 2016

@seang-es Sorry for late reply, I missed your comment.
Unfortunately, this PR validate only creating template. I think the restore logic don't call this logic.

johtani added a commit to johtani/elasticsearch that referenced this pull request Jun 15, 2016
… puts

Share applying template with MetaDataCreateIndexService and MetaDataIndexTemplateService
Add some unit test
Collapse addMappingsToMapperService and move it to MapperService
Extract validateTemplate method
use expectThrows in testcase
Add TODO comment

Related elastic#2415
Backport elastic#8802

(cherry picked from commit fd76291)
johtani added a commit that referenced this pull request Jun 15, 2016
… puts

Share applying template with MetaDataCreateIndexService and MetaDataIndexTemplateService
Add some unit test
Collapse addMappingsToMapperService and move it to MapperService
Extract validateTemplate method
use expectThrows in testcase
Add TODO comment

Related #2415
Backport #8802

(cherry picked from commit fd76291)
@johtani johtani deleted the fix/validate_index_template branch August 23, 2016 06:12
@clintongormley clintongormley added :Data Management/Indices APIs APIs to create and manage indices and templates and removed :Index Templates labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates >enhancement v5.0.0-alpha4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse and validate mappings in index templates when they are put
10 participants