significantly improve log search performance

Signed-off-by: huanggze <loganhuang@yunify.com>
This commit is contained in:
huanggze
2020-07-14 19:18:05 +08:00
parent 0f63b5ba5f
commit 6a5738d66a
7 changed files with 107 additions and 18 deletions

View File

@@ -24,10 +24,11 @@ func New(address string, index string) (*Elastic, error) {
return &Elastic{client: client, index: index}, err
}
func (e *Elastic) Search(body []byte, scroll bool) ([]byte, error) {
func (e *Elastic) Search(indices string, body []byte, scroll bool) ([]byte, error) {
opts := []func(*esapi.SearchRequest){
e.client.Search.WithContext(context.Background()),
e.client.Search.WithIndex(fmt.Sprintf("%s*", e.index)),
e.client.Search.WithIndex(indices),
e.client.Search.WithIgnoreUnavailable(true),
e.client.Search.WithBody(bytes.NewBuffer(body)),
}
if scroll {