Skip to content

fix(deps): update module github.com/elastic/go-elasticsearch/v8 to v9 #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

doctolib-renovate[bot]
Copy link
Contributor

@doctolib-renovate doctolib-renovate bot commented May 9, 2025

This PR contains the following updates:

Package Change Age Confidence
github.com/elastic/go-elasticsearch/v8 v8.17.1 -> v9.0.0 age confidence

Release Notes

elastic/go-elasticsearch (github.com/elastic/go-elasticsearch/v8)

v9.0.0: 9.0.0

Compare Source

  • The client now requires Go 1.23 or later.

New

  • This release introduces an optional package for the TypedAPI named esdsl.
    It provides a domain-specific language (DSL) for building Elasticsearch queries in Go.
    The DSL is designed to simplify query construction, making it easier to build complex queries without writing raw JSON.
// create index
{
    // delete index if exists
    if existsRes, err := es.Indices.Exists("test").IsSuccess(context.Background()); err != nil {
        log.Println(err)
        return
    } else if existsRes {
        if ok, _ := es.Indices.Delete("test").IsSuccess(context.Background()); !ok {
            log.Fatalf("Error deleting index: %v\n", err)
        }
        log.Println("Index deleted:", "test")
    } else {
        log.Println("Index does not exist:", "test")
    }

    mappings := esdsl.NewTypeMapping().
        AddProperty("name", esdsl.NewTextProperty()).
        AddProperty("age", esdsl.NewIntegerNumberProperty())

    createRes, err := es.Indices.Create("test").Mappings(mappings).Do(context.Background())
    if err != nil {
        log.Println(err)
        return
    }

    log.Printf("Index created: %#v\n", createRes)
}

// index document
{
    documents := []Document{
        {"Alice", 30},
        {"Bob", 25},
        {"Charlie", 35},
    }

    bulk := es.Bulk().Index("test")
    for _, document := range documents {
        err := bulk.IndexOp(types.IndexOperation{}, document)
        if err != nil {
            log.Println("Error indexing document:", err)
        }
    }
    bulkRes, err := bulk.Refresh(refresh.Waitfor).Do(context.Background())
    if err != nil {
        log.Println(err)
        return
    }
    if bulkRes.Errors {
        log.Println("Some documents failed to index")
        for _, item := range bulkRes.Items {
            for operationType, responseItem := range item {
                if responseItem.Error != nil {
                    log.Println("Operation:", operationType)
                    log.Println("Response:", responseItem)
                }
            }
        }
    }
    indexedDocs := 0
    for _, item := range bulkRes.Items {
        for _, responseItem := range item {
            if responseItem.Error == nil {
                indexedDocs++
            }
        }
    }

    log.Println("Documents indexed:", indexedDocs)
}

// calculate median age
{
    searchRes, err := es.Search().
        Index("test").
        Size(0).
        AddAggregation("median_age", esdsl.NewPercentilesAggregation().Field("age").Percents(50)).
        Do(context.Background())
    if err != nil {
        log.Println(err)
        return
    }

    if agg, ok := searchRes.Aggregations["median_age"].(*types.TDigestPercentilesAggregate); ok {
        if val, ok := agg.Values.(map[string]interface{})["50.0"]; ok {
            log.Println("Median age:", val)
        }
    }
}

// search documents
{
    matchRes, err := es.Search().
        Index("test").
        Query(esdsl.NewBoolQuery().
            Must(esdsl.NewMatchQuery("name", "Alice")).
            Filter(esdsl.NewNumberRangeQuery("age").Gte(20).Lte(40))).
        Sort(esdsl.NewSortOptions().AddSortOption("age", esdsl.NewFieldSort(sortorder.Asc))).
        Size(10).
        Do(context.Background())
    if err != nil {
        log.Println(err)
        return
    }
    if matchRes.Hits.Total.Value > 0 {
        for _, hit := range matchRes.Hits.Hits {
            doc := Document{}
            err := json.Unmarshal(hit.Source_, &doc)
            if err != nil {
                log.Println("Error unmarshalling document:", err)
                continue
            }
            log.Printf("Document ID: %s, Name: %s, Age: %d\n", *hit.Id_, doc.Name, doc.Age)
        }
    } else {
        log.Println("No documents found")
    }
}

API

  • Updated APIs to 9.0.0

Typed API

v8.18.1: 8.18.1

Compare Source

  • This patch release fixes the broken build found in 8.18.0. If you are using the TypedClient, you should update to this version.

v8.18.0: 8.18.0

Compare Source

  • Update elastictransport to 8.7.0.
  • Thanks to @​zaneli, the TypedClient can now be used in the BulkIndexer.

New

  • This release adds a BaseClient constructor with no attached APIs, allowing it to be used purely as a transport layer instead of a full-featured API client.
baseClient, err := elasticsearch.NewBaseClient(elasticsearch.Config{
    Addresses: []string{
        "http://localhost:9200",
    },
})

if err != nil {
    log.Println(err)
    return
}

res, err := esapi.InfoRequest{
    Pretty:     false,
    Human:      false,
    ErrorTrace: false,
    FilterPath: nil,
    Header:     nil,
    Instrument: baseClient.InstrumentationEnabled(),
}.Do(context.Background(), baseClient)

if err != nil {
    log.Println(err)
    return
}
defer res.Body.Close()
if res.IsError() {
    log.Println("Error response:", res)
    return
}
var infoMap map[string]interface{}
if err := json.NewDecoder(res.Body).Decode(&infoMap); err != nil {
    log.Println("Error parsing response:", err)
    return
}
log.Printf("Elasticsearch version esapi: %s\n", infoMap["version"].(map[string]interface{})["number"])

typedRes, err := info.New(baseClient).Do(context.Background())
if err != nil {
    log.Println(err)
    return
}
log.Printf("Elasticsearch version typedapi: %s\n", typedRes.Version.Int)

API

  • Updated APIs to 8.18.0

Typed API


Configuration

📅 Schedule: Branch creation - Only on Sunday and Saturday ( * * * * 0,6 ) in timezone Europe/Paris, Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was created by Renovate.

Details

Check the default configuration and documentation.

See the logs on Datadog.
To replay this update, you can use the following packageRules on the Manual Run page: [{"matchPackageNames": ["*"], "enabled": false}, {"matchPackageNames": ["github.com/elastic/go-elasticsearch/v8"], "enabled": true}]

@doctolib-renovate
Copy link
Contributor Author

ℹ Artifact update notice

File name: go.mod

In order to perform the update(s) described in the table above, Renovate ran the go get command, which resulted in the following additional change(s):

  • 5 additional dependencies were updated

Details:

Package Change
github.com/elastic/elastic-transport-go/v8 v8.6.1 -> v8.7.0
github.com/google/go-cmp v0.6.0 -> v0.7.0
go.opentelemetry.io/otel v1.31.0 -> v1.35.0
go.opentelemetry.io/otel/metric v1.31.0 -> v1.35.0
go.opentelemetry.io/otel/trace v1.31.0 -> v1.35.0

docto-mergebot
docto-mergebot previously approved these changes May 9, 2025
@docto-mergebot docto-mergebot removed their assignment May 9, 2025
@doctolib-renovate doctolib-renovate bot force-pushed the renovate/github.com-elastic-go-elasticsearch-v8-9.x branch from b75b808 to 4024e8f Compare May 16, 2025 22:12
@doctolib-renovate doctolib-renovate bot changed the title Update module github.com/elastic/go-elasticsearch/v8 to v9 fix(deps): update module github.com/elastic/go-elasticsearch/v8 to v9 May 16, 2025
@doctolib-renovate doctolib-renovate bot force-pushed the renovate/github.com-elastic-go-elasticsearch-v8-9.x branch from 4024e8f to cef4c6b Compare June 20, 2025 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant