Calculating the Number of Logs in opensearch (#5352)

Calculating the Number of Logs

Signed-off-by: chengdehao <dehaocheng@kubesphere.io>

Signed-off-by: chengdehao <dehaocheng@kubesphere.io>
Co-authored-by: chengdehao <dehaocheng@kubesphere.io>
This commit is contained in:
Elon Cheng
2022-11-06 07:03:15 -06:00
committed by GitHub
parent d487af7462
commit ea694684a0
2 changed files with 2 additions and 0 deletions

View File

@@ -64,6 +64,7 @@ func (o *OpenSearch) Search(indices string, body []byte, scroll bool) ([]byte, e
opts := []func(*opensearchapi.SearchRequest){
o.client.Search.WithContext(context.Background()),
o.client.Search.WithIndex(indices),
o.client.Search.WithRestTotalHitsAsInt(true),
o.client.Search.WithIgnoreUnavailable(true),
o.client.Search.WithBody(bytes.NewBuffer(body)),
}

View File

@@ -63,6 +63,7 @@ func New(address string, basicAuth bool, username, password, index string) (*Ope
func (o *OpenSearch) Search(indices string, body []byte, scroll bool) ([]byte, error) {
opts := []func(*opensearchapi.SearchRequest){
o.client.Search.WithContext(context.Background()),
o.client.Search.WithRestTotalHitsAsInt(true),
o.client.Search.WithIndex(indices),
o.client.Search.WithIgnoreUnavailable(true),
o.client.Search.WithBody(bytes.NewBuffer(body)),