Skip to content

Commit e75332f

Browse files
authored
[Typed API] Simplification and builder removal (#545)
* API: Update typed API for Elasticsearch v8.6.0 (ec3159e) * Fix integration tests following API change
1 parent d95f7d3 commit e75332f

File tree

2,412 files changed

+17216
-95742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,412 files changed

+17216
-95742
lines changed

elasticsearch_integration_test.go

+14-19
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"fmt"
2929
"github.com/elastic/go-elasticsearch/v8/typedapi/core/search"
3030
"github.com/elastic/go-elasticsearch/v8/typedapi/indices/create"
31+
"github.com/elastic/go-elasticsearch/v8/typedapi/some"
3132
"github.com/elastic/go-elasticsearch/v8/typedapi/types"
3233
"github.com/elastic/go-elasticsearch/v8/typedapi/types/enums/refresh"
3334
"github.com/elastic/go-elasticsearch/v8/typedapi/types/enums/sortorder"
@@ -339,9 +340,9 @@ func TestTypedClient(t *testing.T) {
339340
res, err := es.Indices.Create(indexName).
340341
Request(&create.Request{
341342
Mappings: &types.TypeMapping{
342-
Properties: map[types.PropertyName]types.Property{
343-
"price": types.NewIntegerNumberPropertyBuilder().Build(),
344-
"name": types.NewKeywordPropertyBuilder().Build(),
343+
Properties: map[string]types.Property{
344+
"price": types.NewIntegerNumberProperty(),
345+
"name": types.NewKeywordProperty(),
345346
},
346347
},
347348
}).
@@ -401,8 +402,8 @@ func TestTypedClient(t *testing.T) {
401402
res, err := es.Search().
402403
Index(indexName).
403404
Request(&search.Request{
404-
Query: &types.QueryContainer{
405-
Match: map[types.Field]types.MatchQuery{
405+
Query: &types.Query{
406+
Match: map[string]types.MatchQuery{
406407
"name": {Query: "Foo"},
407408
},
408409
},
@@ -447,17 +448,16 @@ func TestTypedClient(t *testing.T) {
447448
pa := PriceAggregation{}
448449

449450
size := 0
450-
field := types.Field("price")
451451

452452
totalPricesAgg, err := es.Search().
453453
Index(indexName).
454454
Request(
455455
&search.Request{
456456
Size: &size,
457-
Aggregations: map[string]types.AggregationContainer{
457+
Aggregations: map[string]types.Aggregations{
458458
"total_prices": {
459459
Sum: &types.SumAggregation{
460-
Field: &field,
460+
Field: some.String("price"),
461461
},
462462
},
463463
},
@@ -479,7 +479,7 @@ func TestTypedClient(t *testing.T) {
479479
})
480480

481481
t.Run("Term query from JSON", func(t *testing.T) {
482-
searchRequest, err := search.NewRequestBuilder().FromJSON(`{
482+
searchRequest, err := search.NewRequest().FromJSON(`{
483483
"query": {
484484
"term": {
485485
"user.id": {
@@ -499,16 +499,11 @@ func TestTypedClient(t *testing.T) {
499499
})
500500

501501
t.Run("Sort serialisation", func(t *testing.T) {
502-
qry := search.NewRequestBuilder().Sort(
503-
types.NewSortBuilder().Sort(
504-
[]types.SortCombinations{
505-
types.NewSortCombinationsBuilder().
506-
Field("@timestamp").
507-
SortOptions(types.NewSortOptionsBuilder().
508-
SortOptions(map[types.Field]*types.FieldSortBuilder{
509-
"@timestamp": types.NewFieldSortBuilder().Format("strict_date_optional_time_nanos").Order(sortorder.Asc),
510-
})).Build(),
511-
})).Build()
502+
qry := search.Request{Sort: []types.SortCombinations{
503+
types.SortOptions{SortOptions: map[string]types.FieldSort{
504+
"@timestamp": {Format: some.String("strict_date_optional_time_nanos"), Order: &sortorder.Asc},
505+
}},
506+
}}
512507

513508
data, err := json.Marshal(qry)
514509
if err != nil {

typedapi/api._.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typedapi/asyncsearch/delete/delete.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typedapi/asyncsearch/get/get.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typedapi/asyncsearch/status/status.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)