Skip to content
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

fix: change es version check to support elasticsearch 8+ #4512

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci-elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- major: 7.x
image: 7.14.0
distribution: elasticsearch
- major: 8.x
image: 8.8.0
distribution: elasticsearch
name: ${{ matrix.version.distribution }} ${{ matrix.version.major }}
steps:
- name: Harden Runner
Expand Down
6 changes: 3 additions & 3 deletions pkg/es/wrapper/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c ClientWrapper) Index() es.IndexService {
// Search calls this function to internal client.
func (c ClientWrapper) Search(indices ...string) es.SearchService {
searchService := c.client.Search(indices...)
if c.esVersion == 7 {
if c.esVersion >= 7 {
searchService = searchService.RestTotalHitsAsInt(true)
}
return WrapESSearchService(searchService)
Expand All @@ -75,7 +75,7 @@ func (c ClientWrapper) Search(indices ...string) es.SearchService {
// MultiSearch calls this function to internal client.
func (c ClientWrapper) MultiSearch() es.MultiSearchService {
multiSearchService := c.client.MultiSearch()
if c.esVersion == 7 {
if c.esVersion >= 7 {
multiSearchService = multiSearchService.RestTotalHitsAsInt(true)
}
return WrapESMultiSearchService(multiSearchService)
Expand Down Expand Up @@ -167,7 +167,7 @@ func (i IndexServiceWrapper) Index(index string) es.IndexService {

// Type calls this function to internal service.
func (i IndexServiceWrapper) Type(typ string) es.IndexService {
if i.esVersion == 7 {
if i.esVersion >= 7 {
return WrapESIndexService(i.bulkIndexReq, i.bulkService, i.esVersion)
}
return WrapESIndexService(i.bulkIndexReq.Type(typ), i.bulkService, i.esVersion)
Expand Down
7 changes: 6 additions & 1 deletion scripts/es-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ setup_es() {
--env "http.host=0.0.0.0"
--env "transport.host=127.0.0.1"
--env "xpack.security.enabled=false"
--env "xpack.monitoring.enabled=false"
)
local major_version=${tag%%.*}
if (( major_version < 8 )); then
params+=(
--env "xpack.monitoring.enabled=false"
)
fi
local cid=$(docker run ${params[@]} ${image}:${tag})
echo ${cid}
}
Expand Down