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 include_in_all for multi field #5522

Closed

Conversation

kzwang
Copy link
Contributor

@kzwang kzwang commented Mar 25, 2014

As in document http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#_include_in_all

The include_in_all should be ignored for multi-field. Currently it will set the includeInAll to null, then it will be default to true if index is not set to no. I think it should be set to false instead of null.

btw, seems AllFieldMapper.IncludeInAll.unsetIncludeInAll() will not be used anywhere after this change, should that be removed?

closes #5364

@martijnvg martijnvg self-assigned this Mar 25, 2014
@martijnvg
Copy link
Member

@kzwang Good catch! The reason why I set includeInAll to null, is to not serialise the include_in_all at all if it isn't used. This makes the mapping / cluster state smaller.

I think we can make a different fix, which is similar to the approach in copyTo. In ParseContext we can add a withinMultiFields boolean field and if that is set then the ParseContext#includeInAll(Boolean,boolean) return false. The withinMultiFields boolean field should be set to true in the AbstractFieldMapper.MultiFields#parse(ABF, ParseContext) and be set back to false once it exits that method.

@kzwang
Copy link
Contributor Author

kzwang commented Mar 25, 2014

@martijnvg yes, that's better. I'll modify the PR to do that

@martijnvg
Copy link
Member

@kzwang Great!

@kzwang
Copy link
Contributor Author

kzwang commented Mar 25, 2014

@martijnvg I've updated the PR

@@ -348,7 +361,7 @@ public void version(Field version) {
}

public boolean includeInAll(Boolean includeInAll, FieldMapper mapper) {
return includeInAll(includeInAll, mapper.fieldType().indexed());
return !isWithinMultiFields() && includeInAll(includeInAll, mapper.fieldType().indexed());
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this line can add the following to the method being (includeInAll with the two booleans) invoked here?

if (withinMultiFields) {
   return false;
}

Then it will be consistent with withinCopyTo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martijnvg fixed

@martijnvg
Copy link
Member

Looks good! I left one comment.

this.withinMultiFields = false;
}

public boolean isWithinMultiFields() {
Copy link
Member

Choose a reason for hiding this comment

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

This method can be removed since it isn't used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martijnvg removed this method

@martijnvg
Copy link
Member

I left more one comment, you wan to change that? Other then that it looks good to me and I'll merge it in then.

martijnvg pushed a commit that referenced this pull request Mar 25, 2014
@martijnvg martijnvg closed this in 0ee889f Mar 25, 2014
@martijnvg
Copy link
Member

Thanks @kzwang your fix has been added to the master and 1.x branches

@kzwang kzwang deleted the feature/multi_field_include_in_all branch March 25, 2014 10:12
martijnvg pushed a commit that referenced this pull request Mar 27, 2014
@martijnvg
Copy link
Member

Also backported it to 1.1 branch, so the fix will be in version 1.1.1 as well.

@clintongormley clintongormley changed the title fix include_in_all for multi field Fix include_in_all for multi field Jun 7, 2015
@clintongormley clintongormley added the :Search/Mapping Index mappings, including merging and defining field types label Jun 7, 2015
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Mapping Index mappings, including merging and defining field types v1.1.1 v1.2.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"include_in_all": false not working for nested multi-field mappings
3 participants