@@ -126,6 +126,33 @@ public void testUseBloomFilterWithTimestampFieldEnabled_disableBloomFilter() thr
126126 );
127127 }
128128
129+ public void testUseEs812PostingsFormat () throws IOException {
130+ PerFieldFormatSupplier perFieldMapperCodec ;
131+
132+ // standard index mode
133+ perFieldMapperCodec = createFormatSupplier (false , false , IndexMode .STANDARD , MAPPING_1 );
134+ assertThat (perFieldMapperCodec .getPostingsFormatForField ("gauge" ), instanceOf (Lucene103PostingsFormat .class ));
135+
136+ perFieldMapperCodec = createFormatSupplier (false , true , IndexMode .STANDARD , MAPPING_1 );
137+ assertThat (perFieldMapperCodec .getPostingsFormatForField ("gauge" ), instanceOf (ES812PostingsFormat .class ));
138+
139+ // LogsDB index mode
140+ // by default, logsdb uses the ES 8.12 postings format
141+ perFieldMapperCodec = createFormatSupplier (false , false , IndexMode .LOGSDB , MAPPING_3 );
142+ assertThat (perFieldMapperCodec .getPostingsFormatForField ("message" ), instanceOf (ES812PostingsFormat .class ));
143+
144+ perFieldMapperCodec = createFormatSupplier (false , true , IndexMode .LOGSDB , MAPPING_3 );
145+ assertThat (perFieldMapperCodec .getPostingsFormatForField ("message" ), instanceOf (ES812PostingsFormat .class ));
146+
147+ // time series index mode
148+ // by default, logsdb uses the ES 8.12 postings format
149+ perFieldMapperCodec = createFormatSupplier (false , false , IndexMode .TIME_SERIES , MAPPING_1 );
150+ assertThat (perFieldMapperCodec .getPostingsFormatForField ("gauge" ), instanceOf (ES812PostingsFormat .class ));
151+
152+ perFieldMapperCodec = createFormatSupplier (false , true , IndexMode .TIME_SERIES , MAPPING_1 );
153+ assertThat (perFieldMapperCodec .getPostingsFormatForField ("gauge" ), instanceOf (ES812PostingsFormat .class ));
154+ }
155+
129156 public void testUseES87TSDBEncodingForTimestampField () throws IOException {
130157 PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (true , true , true );
131158 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("@timestamp" )), is (true ));
@@ -137,13 +164,13 @@ public void testDoNotUseES87TSDBEncodingForTimestampFieldNonTimeSeriesIndex() th
137164 }
138165
139166 public void testEnableES87TSDBCodec () throws IOException {
140- PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (true , IndexMode .TIME_SERIES , MAPPING_1 );
167+ PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (true , false , IndexMode .TIME_SERIES , MAPPING_1 );
141168 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("gauge" )), is (true ));
142169 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("@timestamp" )), is (true ));
143170 }
144171
145172 public void testDisableES87TSDBCodec () throws IOException {
146- PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (false , IndexMode .TIME_SERIES , MAPPING_1 );
173+ PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (false , false , IndexMode .TIME_SERIES , MAPPING_1 );
147174 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("gauge" )), is (false ));
148175 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("@timestamp" )), is (false ));
149176 }
@@ -178,7 +205,7 @@ private PerFieldFormatSupplier createFormatSupplier(boolean timestampField, bool
178205 }
179206
180207 public void testUseES87TSDBEncodingSettingDisabled () throws IOException {
181- PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (false , IndexMode .TIME_SERIES , MAPPING_2 );
208+ PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (false , false , IndexMode .TIME_SERIES , MAPPING_2 );
182209 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("@timestamp" )), is (false ));
183210 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("counter" )), is (false ));
184211 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("gauge" )), is (false ));
@@ -192,14 +219,14 @@ public void testUseTimeSeriesModeDisabledCodecDisabled() throws IOException {
192219 }
193220
194221 public void testUseTimeSeriesDocValuesCodecSetting () throws IOException {
195- PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (true , null , IndexMode .STANDARD , MAPPING_2 );
222+ PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (true , null , false , IndexMode .STANDARD , MAPPING_2 );
196223 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("@timestamp" )), is (true ));
197224 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("counter" )), is (true ));
198225 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("gauge" )), is (true ));
199226 }
200227
201228 public void testUseTimeSeriesModeAndCodecEnabled () throws IOException {
202- PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (true , IndexMode .TIME_SERIES , MAPPING_2 );
229+ PerFieldFormatSupplier perFieldMapperCodec = createFormatSupplier (true , false , IndexMode .TIME_SERIES , MAPPING_2 );
203230 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("@timestamp" )), is (true ));
204231 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("counter" )), is (true ));
205232 assertThat ((perFieldMapperCodec .useTSDBDocValuesFormat ("gauge" )), is (true ));
@@ -227,16 +254,22 @@ public void testSeqnoField() throws IOException {
227254 }
228255
229256 private PerFieldFormatSupplier createFormatSupplier (IndexMode mode , String mapping ) throws IOException {
230- return createFormatSupplier (null , mode , mapping );
257+ return createFormatSupplier (null , false , mode , mapping );
231258 }
232259
233- private PerFieldFormatSupplier createFormatSupplier (Boolean enableES87TSDBCodec , IndexMode mode , String mapping ) throws IOException {
234- return createFormatSupplier (null , enableES87TSDBCodec , mode , mapping );
260+ private PerFieldFormatSupplier createFormatSupplier (
261+ Boolean enableES87TSDBCodec ,
262+ Boolean useEs812PostingsFormat ,
263+ IndexMode mode ,
264+ String mapping
265+ ) throws IOException {
266+ return createFormatSupplier (null , enableES87TSDBCodec , useEs812PostingsFormat , mode , mapping );
235267 }
236268
237269 private PerFieldFormatSupplier createFormatSupplier (
238270 Boolean useTimeSeriesDocValuesFormatSetting ,
239271 Boolean enableES87TSDBCodec ,
272+ Boolean useEs812PostingsFormat ,
240273 IndexMode mode ,
241274 String mapping
242275 ) throws IOException {
@@ -251,6 +284,9 @@ private PerFieldFormatSupplier createFormatSupplier(
251284 if (useTimeSeriesDocValuesFormatSetting != null ) {
252285 settings .put (IndexSettings .USE_TIME_SERIES_DOC_VALUES_FORMAT_SETTING .getKey (), useTimeSeriesDocValuesFormatSetting );
253286 }
287+ if (useEs812PostingsFormat ) {
288+ settings .put (IndexSettings .USE_ES_812_POSTINGS_FORMAT .getKey (), true );
289+ }
254290 MapperService mapperService = MapperTestUtils .newMapperService (xContentRegistry (), createTempDir (), settings .build (), "test" );
255291 mapperService .merge ("type" , new CompressedXContent (mapping ), MapperService .MergeReason .MAPPING_UPDATE );
256292 return new PerFieldFormatSupplier (mapperService , BigArrays .NON_RECYCLING_INSTANCE );
0 commit comments