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

Take into account `_default_ mapping` in index template when parsing alias filter in index templates. #8577

Conversation

Projects
None yet
4 participants
@martijnvg
Copy link
Member

commented Nov 20, 2014

By also taking into account the type for an index request that indexes into index that doesn't exist in the automatic create index request, the mapping for the new type will take over the _default_ mapping. Alias filters that then point to fields in the _default_ mapping will then not fail.

PR for #8473

@s1monw

View changes

src/main/java/org/elasticsearch/action/index/TransportIndexAction.java Outdated
@@ -83,7 +83,7 @@ protected void doExecute(final IndexRequest request, final ActionListener<IndexR
// if we don't have a master, we don't have metadata, that's fine, let it find a master using create index API
if (autoCreateIndex.shouldAutoCreate(request.index(), clusterService.state())) {
request.beforeLocalFork(); // we fork on another thread...
createIndexAction.execute(new CreateIndexRequest(request).index(request.index()).cause("auto(index api)").masterNodeTimeout(request.timeout()), new ActionListener<CreateIndexResponse>() {
createIndexAction.execute(new CreateIndexRequest(request).index(request.index()).mapping(request.type()).cause("auto(index api)").masterNodeTimeout(request.timeout()), new ActionListener<CreateIndexResponse>() {

This comment has been minimized.

Copy link
@s1monw

s1monw Nov 21, 2014

Contributor

can we maybe un-chain this line it's very hard to read... like

CreateIndexRequest indexReq = new CreateIndexRequest(request);
indexReq.mapping(request.type());
//...

This comment has been minimized.

Copy link
@jpountz

jpountz Nov 21, 2014

Contributor

Is it still going to work if you create a type dynamically (through an indexing request) on an index that already exists?

This comment has been minimized.

Copy link
@martijnvg

martijnvg Nov 21, 2014

Author Member

Yes, this makes sure that an empty mapping gets added on the master. If there is a default mapping than the mapping will not be empty. If the mapping wouldn't be created on the master then alias validation would fail because of the strict field resolution requirement added in 1.4.0.

On the node that received the index request that mapping still get created locally and eventually gets merged with what exists on master. (which should exactly be the same)

@s1monw

This comment has been minimized.

Copy link
Contributor

commented Nov 21, 2014

Left a small comment otherwise LGTM

@s1monw s1monw removed the review label Nov 21, 2014

@martijnvg

This comment has been minimized.

Copy link
Member Author

commented Nov 21, 2014

Updated the PR to not chain the create index request.

@s1monw

This comment has been minimized.

Copy link
Contributor

commented Nov 23, 2014

thanks LGTM

@s1monw

This comment has been minimized.

Copy link
Contributor

commented Nov 24, 2014

@martijnvg can you please get this in?

@martijnvg martijnvg force-pushed the martijnvg:bugs/strict_alias_filter_parsing_via_templates branch Nov 24, 2014

Core: Fields defined in the `_default_` mapping of an index template …
…should be picked up when an index alias filter is parsed if a new index is introduced when a document is indexed into an index that doesn't exist yet.

Closes #8473

@martijnvg martijnvg force-pushed the martijnvg:bugs/strict_alias_filter_parsing_via_templates branch to 63db0b9 Nov 24, 2014

@martijnvg martijnvg merged commit 63db0b9 into elastic:1.x Nov 24, 2014

@clintongormley clintongormley changed the title Take into account _default_ mapping in index template when parsing alias filter in index templates. Aliases: Take into account _default_ mapping in index template when parsing alias filter in index templates. Nov 25, 2014

@martijnvg martijnvg deleted the martijnvg:bugs/strict_alias_filter_parsing_via_templates branch May 18, 2015

@clintongormley clintongormley changed the title Aliases: Take into account _default_ mapping in index template when parsing alias filter in index templates. Take into account `_default_ mapping` in index template when parsing alias filter in index templates. Jun 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.