19
19
20
20
package org .elasticsearch .index .mapper ;
21
21
22
+ import org .apache .lucene .index .DocValuesType ;
22
23
import org .apache .lucene .index .IndexableField ;
23
24
import org .apache .lucene .util .BytesRef ;
24
25
import org .elasticsearch .common .Strings ;
@@ -87,6 +88,7 @@ public void testDefaults() throws Exception {
87
88
assertEquals (new BytesRef ("value" ), fields [0 ].binaryValue ());
88
89
assertFalse (fields [0 ].fieldType ().stored ());
89
90
assertTrue (fields [0 ].fieldType ().omitNorms ());
91
+ assertEquals (DocValuesType .NONE , fields [0 ].fieldType ().docValuesType ());
90
92
91
93
IndexableField [] keyedFields = parsedDoc .rootDoc ().getFields ("field._keyed" );
92
94
assertEquals (1 , keyedFields .length );
@@ -95,6 +97,7 @@ public void testDefaults() throws Exception {
95
97
assertEquals (new BytesRef ("key\0 value" ), keyedFields [0 ].binaryValue ());
96
98
assertFalse (keyedFields [0 ].fieldType ().stored ());
97
99
assertTrue (keyedFields [0 ].fieldType ().omitNorms ());
100
+ assertEquals (DocValuesType .NONE , keyedFields [0 ].fieldType ().docValuesType ());
98
101
99
102
IndexableField [] fieldNamesFields = parsedDoc .rootDoc ().getFields (FieldNamesFieldMapper .NAME );
100
103
assertEquals (1 , fieldNamesFields .length );
@@ -127,6 +130,23 @@ public void testDisableIndex() throws Exception {
127
130
assertEquals (0 , fields .length );
128
131
}
129
132
133
+ public void testEnableDocValues () throws Exception {
134
+ String mapping = Strings .toString (XContentFactory .jsonBuilder ().startObject ()
135
+ .startObject ("type" )
136
+ .startObject ("properties" )
137
+ .startObject ("field" )
138
+ .field ("type" , "json" )
139
+ .field ("doc_values" , true )
140
+ .endObject ()
141
+ .endObject ()
142
+ .endObject ()
143
+ .endObject ());
144
+
145
+ IllegalArgumentException e = expectThrows (IllegalArgumentException .class ,
146
+ () -> parser .parse ("type" , new CompressedXContent (mapping )));
147
+ assertEquals ("[json] fields do not support doc values" , e .getMessage ());
148
+ }
149
+
130
150
public void testEnableStore () throws Exception {
131
151
String mapping = Strings .toString (XContentFactory .jsonBuilder ().startObject ()
132
152
.startObject ("type" )
0 commit comments