@@ -1377,29 +1377,28 @@ public void shouldThrowAnExceptionWhenNoIndexSpecifiedForCountQuery() {
1377
1377
@ Test
1378
1378
public void shouldCreateIndexWithGivenSettings () {
1379
1379
// given
1380
- String settings =
1381
- "{ " +
1382
- "\" settings\" : { " +
1383
- "\" index\" : { " +
1384
- "\" analysis\" :{ " +
1385
- "\" analyzer\" : { " +
1386
- "\" email-analyzer\" : { " +
1387
- "\" type\" : \" custom\" ," +
1388
- "\" tokenizer\" : \" uax_url_email\" ," +
1389
- "\" filter\" : [\" standard\" , \" lowercase\" , \" stop\" ]\n " +
1390
- "}\n " +
1391
- "}\n " +
1392
- "}\n " +
1393
- "}\n " +
1394
- "}\n " +
1395
- "}" ;
1380
+ String settings = "{\n " +
1381
+ " \" index\" : {\n " +
1382
+ " \" number_of_shards\" : \" 1\" ,\n " +
1383
+ " \" number_of_replicas\" : \" 0\" ,\n " +
1384
+ " \" analysis\" : {\n " +
1385
+ " \" analyzer\" : {\n " +
1386
+ " \" emailAnalyzer\" : {\n " +
1387
+ " \" type\" : \" custom\" ,\n " +
1388
+ " \" tokenizer\" : \" uax_url_email\" \n " +
1389
+ " }\n " +
1390
+ " }\n " +
1391
+ " }\n " +
1392
+ " }\n " +
1393
+ "}" ;
1394
+
1396
1395
elasticsearchTemplate .deleteIndex ("test-index" );
1397
1396
// when
1398
1397
elasticsearchTemplate .createIndex ("test-index" , settings );
1399
1398
// then
1400
1399
Map map = elasticsearchTemplate .getSetting ("test-index" );
1401
- boolean hasAnalyzer = map .containsKey ("index.settings.index. analysis.analyzer.email-analyzer .tokenizer" );
1402
- String emailAnalyzer = (String ) map .get ("index.settings.index. analysis.analyzer.email-analyzer .tokenizer" );
1400
+ boolean hasAnalyzer = map .containsKey ("index.analysis.analyzer.emailAnalyzer .tokenizer" );
1401
+ String emailAnalyzer = (String ) map .get ("index.analysis.analyzer.emailAnalyzer .tokenizer" );
1403
1402
assertThat (elasticsearchTemplate .indexExists ("test-index" ), is (true ));
1404
1403
assertThat (hasAnalyzer , is (true ));
1405
1404
assertThat (emailAnalyzer , is ("uax_url_email" ));
@@ -1426,6 +1425,39 @@ public void shouldCreateGivenSettingsForGivenIndex() {
1426
1425
assertThat ((String ) map .get ("index.store.type" ), is ("memory" ));
1427
1426
}
1428
1427
1428
+ /*
1429
+ DATAES-88
1430
+ */
1431
+ @ Test
1432
+ public void shouldCreateIndexWithGivenClassAndSettings () {
1433
+ //given
1434
+ String settings = "{\n " +
1435
+ " \" index\" : {\n " +
1436
+ " \" number_of_shards\" : \" 1\" ,\n " +
1437
+ " \" number_of_replicas\" : \" 0\" ,\n " +
1438
+ " \" analysis\" : {\n " +
1439
+ " \" analyzer\" : {\n " +
1440
+ " \" emailAnalyzer\" : {\n " +
1441
+ " \" type\" : \" custom\" ,\n " +
1442
+ " \" tokenizer\" : \" uax_url_email\" \n " +
1443
+ " }\n " +
1444
+ " }\n " +
1445
+ " }\n " +
1446
+ " }\n " +
1447
+ "}" ;
1448
+
1449
+ elasticsearchTemplate .deleteIndex (SampleEntity .class );
1450
+ elasticsearchTemplate .createIndex (SampleEntity .class , settings );
1451
+ elasticsearchTemplate .refresh (SampleEntity .class , true );
1452
+
1453
+ // then
1454
+ Map map = elasticsearchTemplate .getSetting (SampleEntity .class );
1455
+ assertThat (elasticsearchTemplate .indexExists ("test-index" ), is (true ));
1456
+ assertThat (map .containsKey ("index.number_of_replicas" ), is (true ));
1457
+ assertThat (map .containsKey ("index.number_of_shards" ), is (true ));
1458
+ assertThat ((String ) map .get ("index.number_of_replicas" ), is ("0" ));
1459
+ assertThat ((String ) map .get ("index.number_of_shards" ), is ("1" ));
1460
+ }
1429
1461
1430
1462
@ Test
1431
1463
public void shouldTestResultsAcrossMultipleIndices () {
0 commit comments