Skip to content

Commit

Permalink
The binary field shouldn't be stored by default, because it is alread…
Browse files Browse the repository at this point in the history
…y available in the _source.
  • Loading branch information
martijnvg committed Jan 31, 2014
1 parent b9707b3 commit 0d9197a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
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));
}

}

0 comments on commit 0d9197a

Please sign in to comment.