@@ -335,16 +335,14 @@ func TestTypedClient(t *testing.T) {
335335 indexName := "test-index"
336336 if ok , err := es .Indices .Exists (indexName ).IsSuccess (nil ); ! ok && err == nil {
337337 res , err := es .Indices .Create (indexName ).
338- Request (create .NewRequestBuilder ().
339- Mappings (
340- types .NewTypeMappingBuilder ().
341- Properties (
342- map [types.PropertyName ]* types.PropertyBuilder {
343- "price" : types .NewPropertyBuilder ().IntegerNumberProperty (types .NewIntegerNumberPropertyBuilder ()),
344- "name" : types .NewPropertyBuilder ().KeywordProperty (types .NewKeywordPropertyBuilder ()),
345- },
346- ),
347- ).Build ()).
338+ Request (& create.Request {
339+ Mappings : & types.TypeMapping {
340+ Properties : map [types.PropertyName ]types.Property {
341+ "price" : types .NewIntegerNumberPropertyBuilder ().Build (),
342+ "name" : types .NewKeywordPropertyBuilder ().Build (),
343+ },
344+ },
345+ }).
348346 Do (nil )
349347 if err != nil {
350348 t .Fatalf ("error creating index test-index: %s" , err )
@@ -387,7 +385,7 @@ func TestTypedClient(t *testing.T) {
387385 Request (document ).
388386 Id (strconv .Itoa (document .Id )).
389387 Refresh (refresh .Waitfor ).
390- Do (nil )
388+ Do (context . Background () )
391389 if err != nil {
392390 t .Fatalf ("error indexing document: %s" , err )
393391 }
@@ -400,14 +398,13 @@ func TestTypedClient(t *testing.T) {
400398
401399 res , err := es .Search ().
402400 Index (indexName ).
403- Request (search .NewRequestBuilder ().
404- Query (
405- types .NewQueryContainerBuilder ().
406- Match (map [types.Field ]* types.MatchQueryBuilder {
407- "name" : types .NewMatchQueryBuilder ().Query ("Foo" ),
408- }),
409- ).Build (),
410- ).Do (nil )
401+ Request (& search.Request {
402+ Query : & types.QueryContainer {
403+ Match : map [types.Field ]types.MatchQuery {
404+ "name" : {Query : "Foo" },
405+ },
406+ },
407+ }).Do (context .Background ())
411408
412409 if err != nil {
413410 t .Fatalf ("error runnning search query: %s" , err )
@@ -447,18 +444,22 @@ func TestTypedClient(t *testing.T) {
447444
448445 pa := PriceAggregation {}
449446
447+ size := 0
448+ field := types .Field ("price" )
449+
450450 totalPricesAgg , err := es .Search ().
451451 Index (indexName ).
452452 Request (
453- search .NewRequestBuilder ().
454- Size (0 ).
455- Aggregations (
456- map [string ]* types.AggregationContainerBuilder {
457- "total_prices" : types .NewAggregationContainerBuilder ().
458- Sum (types .NewSumAggregationBuilder ().Field ("price" )),
459- }).
460- Build (),
461- ).Do (nil )
453+ & search.Request {
454+ Size : & size ,
455+ Aggregations : map [string ]types.AggregationContainer {
456+ "total_prices" : {
457+ Sum : & types.SumAggregation {
458+ Field : & field ,
459+ },
460+ },
461+ },
462+ }).Do (context .Background ())
462463
463464 if err != nil {
464465 t .Fatal (err )
0 commit comments