@@ -10,24 +10,25 @@ public class NotAnalyzedTests : IntegrationTests
1010 [ Test ]
1111 public void NotAnalyzedReturnsOneItem ( )
1212 {
13- this . _client . DeleteMapping < ElasticSearchProject > ( ) ;
14- this . _client . DeleteMapping < ElasticSearchProject > ( ElasticsearchConfiguration . DefaultIndex + "_clone" ) ;
15- this . _client . CreateIndex ( ElasticsearchConfiguration . DefaultIndex , new IndexSettings ( ) ) ;
16- var x = this . _client . MapFromAttributes < ElasticSearchProject > ( ) ;
13+ var index = ElasticsearchConfiguration . NewUniqueIndexName ( ) ;
14+ var x = this . _client . CreateIndex ( index , s => s
15+ . AddMapping < ElasticSearchProject > ( m => m . MapFromAttributes ( ) )
16+ ) ;
1717 Assert . IsTrue ( x . OK , x . ConnectionStatus . ToString ( ) ) ;
1818
19- var typeMapping = this . _client . GetMapping ( ElasticsearchConfiguration . DefaultIndex , "elasticsearchprojects" ) ;
19+ var typeMapping = this . _client . GetMapping ( index , "elasticsearchprojects" ) ;
2020 var mapping = typeMapping . Properties [ "country" ] as StringMapping ;
2121 Assert . NotNull ( mapping ) ;
2222 Assert . AreEqual ( FieldIndexOption . not_analyzed , mapping . Index ) ;
2323
2424 var indexResult = this . _client . Index ( new ElasticSearchProject
2525 {
2626 Country = "The Royal Kingdom Of The Netherlands"
27- } , new IndexParameters { Refresh = true } ) ;
27+ } , indexParameters : new IndexParameters { Refresh = true } , index : index ) ;
2828 Assert . IsTrue ( indexResult . IsValid ) ;
2929
3030 var result = this . _client . Search < ElasticSearchProject > ( s=> s
31+ . Index ( index )
3132 . FacetTerm ( ft=> ft . OnField ( f=> f . Country ) )
3233 . MatchAll ( )
3334 ) ;
@@ -37,27 +38,30 @@ public void NotAnalyzedReturnsOneItem()
3738 }
3839
3940 [ Test ]
40- public void AnalyzedReturnsTwoItems ( )
41+ public void AnalyzedReturnsMoreItems ( )
4142 {
42- this . _client . DeleteMapping < ElasticSearchProject > ( ) ;
43- var x = this . _client . MapFromAttributes < ElasticSearchProject > ( ) ;
44- Assert . IsTrue ( x . OK ) ;
45-
46- var typeMapping = this . _client . GetMapping ( ElasticsearchConfiguration . DefaultIndex , "elasticsearchprojects" ) ;
47- this . _client . DeleteMapping < ElasticSearchProject > ( ) ;
48- var mapping = typeMapping . Properties [ "country" ] as StringMapping ;
49- Assert . NotNull ( mapping ) ;
50- mapping . Index = FieldIndexOption . analyzed ;
51- var updateMapResult = this . _client . Map ( typeMapping ) ;
52- Assert . True ( updateMapResult . IsValid ) ;
43+ var index = ElasticsearchConfiguration . NewUniqueIndexName ( ) ;
44+ var x = this . _client . CreateIndex ( index , s => s
45+ . AddMapping < ElasticSearchProject > ( m => m
46+ . MapFromAttributes ( )
47+ . Properties ( pp=> pp
48+ . String ( pps=> pps . Name ( p=> p . Country ) . Index ( FieldIndexOption . analyzed ) )
49+ )
50+ )
51+ ) ;
52+ Assert . IsTrue ( x . OK , x . ConnectionStatus . ToString ( ) ) ;
5353
54- var indexResult = this . _client . Index ( new ElasticSearchProject
55- {
56- Country = "The Royal Kingdom Of The Netherlands"
57- } , new IndexParameters { Refresh = true } ) ;
54+ var indexResult = this . _client . Index (
55+ new ElasticSearchProject
56+ {
57+ Country = "The Royal Kingdom Of The Netherlands"
58+ } ,
59+ indexParameters : new IndexParameters { Refresh = true }
60+ , index : index ) ;
5861 Assert . IsTrue ( indexResult . IsValid ) ;
5962
6063 var result = this . _client . Search < ElasticSearchProject > ( s => s
64+ . Index ( index )
6165 . FacetTerm ( ft => ft . OnField ( f => f . Country ) )
6266 . MatchAll ( )
6367 ) ;
0 commit comments