@@ -1436,7 +1436,7 @@ public void testEmpty() throws Exception {
14361436 });
14371437 }
14381438
1439- public void testNormalizeByDefault () throws IOException {
1439+ public void testNormsEnabledByDefault () throws IOException {
14401440 // given
14411441 Settings .Builder indexSettingsBuilder = getIndexSettingsBuilder ();
14421442 indexSettingsBuilder .put (IndexSettings .MODE .getKey (), IndexMode .STANDARD .getName ());
@@ -1461,7 +1461,7 @@ public void testNormalizeByDefault() throws IOException {
14611461 assertThat (fieldType .omitNorms (), is (false ));
14621462 }
14631463
1464- public void testNormalizeWhenIndexModeIsNotGiven () throws IOException {
1464+ public void testNormsEnabledWhenIndexModeIsNotGiven () throws IOException {
14651465 // given
14661466 Settings .Builder indexSettingsBuilder = getIndexSettingsBuilder ();
14671467 Settings indexSettings = indexSettingsBuilder .build ();
@@ -1485,7 +1485,7 @@ public void testNormalizeWhenIndexModeIsNotGiven() throws IOException {
14851485 assertThat (fieldType .omitNorms (), is (false ));
14861486 }
14871487
1488- public void testNormalizeWhenIndexModeIsNull () throws IOException {
1488+ public void textNormsEnabledWhenIndexModeIsNull () throws IOException {
14891489 // given
14901490 Settings .Builder indexSettingsBuilder = getIndexSettingsBuilder ();
14911491 indexSettingsBuilder .put (IndexSettings .MODE .getKey (), (String ) null );
@@ -1510,7 +1510,7 @@ public void testNormalizeWhenIndexModeIsNull() throws IOException {
15101510 assertThat (fieldType .omitNorms (), is (false ));
15111511 }
15121512
1513- public void testDontNormalizeWhenIndexModeIsLogsDB () throws IOException {
1513+ public void testNormsDisabledWhenIndexModeIsLogsDb () throws IOException {
15141514 // given
15151515 Settings .Builder indexSettingsBuilder = getIndexSettingsBuilder ();
15161516 indexSettingsBuilder .put (IndexSettings .MODE .getKey (), IndexMode .LOGSDB .getName ());
@@ -1538,7 +1538,7 @@ public void testDontNormalizeWhenIndexModeIsLogsDB() throws IOException {
15381538 assertThat (fieldType .omitNorms (), is (true ));
15391539 }
15401540
1541- public void testDontNormalizeWhenIndexModeIsTSDB () throws IOException {
1541+ public void testNormsDisabledWhenIndexModeIsTsdb () throws IOException {
15421542 // given
15431543 Instant currentTime = Instant .now ();
15441544 Settings .Builder indexSettingsBuilder = getIndexSettingsBuilder ();
@@ -1574,4 +1574,70 @@ public void testDontNormalizeWhenIndexModeIsTSDB() throws IOException {
15741574 assertThat (fieldType .omitNorms (), is (true ));
15751575 }
15761576
1577+ public void testNormsEnabledWhenIndexModeIsLogsDb_bwcCheck () throws IOException {
1578+ // given
1579+ Settings .Builder indexSettingsBuilder = getIndexSettingsBuilder ();
1580+ indexSettingsBuilder .put (IndexSettings .MODE .getKey (), IndexMode .LOGSDB .getName ());
1581+ Settings indexSettings = indexSettingsBuilder .build ();
1582+
1583+ XContentBuilder mapping = mapping (b -> {
1584+ b .startObject ("potato" );
1585+ b .field ("type" , "text" );
1586+ b .endObject ();
1587+ });
1588+
1589+ var source = source (b -> {
1590+ b .field ("@timestamp" , Instant .now ());
1591+ b .field ("potato" , "a potato flew around my room" );
1592+ });
1593+
1594+ // when
1595+ IndexVersion bwcIndexVersion = IndexVersions .EXCLUDE_SOURCE_VECTORS_DEFAULT ;
1596+ DocumentMapper mapper = createMapperService (bwcIndexVersion , indexSettings , mapping ).documentMapper ();
1597+ ParsedDocument doc = mapper .parse (source );
1598+
1599+ List <IndexableField > fields = doc .rootDoc ().getFields ("potato" );
1600+ IndexableFieldType fieldType = fields .get (0 ).fieldType ();
1601+
1602+ // then
1603+ assertThat (fieldType .omitNorms (), is (false ));
1604+ }
1605+
1606+ public void testNormsEnabledWhenIndexModeIsTsdb_bwcCheck () throws IOException {
1607+ // given
1608+ Instant currentTime = Instant .now ();
1609+ Settings .Builder indexSettingsBuilder = getIndexSettingsBuilder ();
1610+ indexSettingsBuilder .put (IndexSettings .MODE .getKey (), IndexMode .TIME_SERIES .getName ())
1611+ .put (IndexSettings .TIME_SERIES_START_TIME .getKey (), currentTime .minus (1 , ChronoUnit .HOURS ).toEpochMilli ())
1612+ .put (IndexSettings .TIME_SERIES_END_TIME .getKey (), currentTime .plus (1 , ChronoUnit .HOURS ).toEpochMilli ())
1613+ .put (IndexMetadata .INDEX_ROUTING_PATH .getKey (), "dimension" );
1614+ Settings indexSettings = indexSettingsBuilder .build ();
1615+
1616+ XContentBuilder mapping = mapping (b -> {
1617+ b .startObject ("potato" );
1618+ b .field ("type" , "text" );
1619+ b .endObject ();
1620+
1621+ b .startObject ("@timestamp" );
1622+ b .field ("type" , "date" );
1623+ b .endObject ();
1624+ });
1625+
1626+ var source = source (TimeSeriesRoutingHashFieldMapper .DUMMY_ENCODED_VALUE , b -> {
1627+ b .field ("@timestamp" , Instant .now ());
1628+ b .field ("potato" , "a potato flew around my room" );
1629+ }, null );
1630+
1631+ // when
1632+ IndexVersion bwcIndexVersion = IndexVersions .EXCLUDE_SOURCE_VECTORS_DEFAULT ;
1633+ DocumentMapper mapper = createMapperService (bwcIndexVersion , indexSettings , mapping ).documentMapper ();
1634+ ParsedDocument doc = mapper .parse (source );
1635+
1636+ List <IndexableField > fields = doc .rootDoc ().getFields ("potato" );
1637+ IndexableFieldType fieldType = fields .get (0 ).fieldType ();
1638+
1639+ // then
1640+ assertThat (fieldType .omitNorms (), is (false ));
1641+ }
1642+
15771643}
0 commit comments