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

The binary field shouldn't be stored by default, because it is already available in the _source #4957

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -59,7 +59,6 @@ public static class Defaults extends AbstractFieldMapper.Defaults {

static {
FIELD_TYPE.setIndexed(false);
FIELD_TYPE.setStored(true);
FIELD_TYPE.freeze();
}
}
Expand Down
@@ -0,0 +1,35 @@
package org.elasticsearch.index.mapper.binary;

import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperTestUtils;
import org.elasticsearch.index.mapper.core.BinaryFieldMapper;
import org.elasticsearch.test.ElasticsearchTestCase;
import org.junit.Test;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;

/**
*/
public class BinaryMappingTests extends ElasticsearchTestCase {

@Test
public void testDefaultMapping() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties")
.startObject("field")
.field("type", "binary")
.endObject()
.endObject()
.endObject().endObject().string();

DocumentMapper mapper = MapperTestUtils.newParser().parse(mapping);

FieldMapper fieldMapper = mapper.mappers().smartNameFieldMapper("field");
assertThat(fieldMapper, instanceOf(BinaryFieldMapper.class));
assertThat(fieldMapper.fieldType().stored(), equalTo(false));
}

}