|
|
|
@ -19,7 +19,8 @@ package es |
|
|
|
|
import ( |
|
|
|
|
"context" |
|
|
|
|
"fmt" |
|
|
|
|
"github.com/coze-dev/coze-studio/backend/pkg/parsex" |
|
|
|
|
"os" |
|
|
|
|
|
|
|
|
|
"github.com/elastic/go-elasticsearch/v8" |
|
|
|
|
"github.com/elastic/go-elasticsearch/v8/esutil" |
|
|
|
|
"github.com/elastic/go-elasticsearch/v8/typedapi/core/search" |
|
|
|
@ -30,7 +31,6 @@ import ( |
|
|
|
|
"github.com/elastic/go-elasticsearch/v8/typedapi/types/enums/operator" |
|
|
|
|
"github.com/elastic/go-elasticsearch/v8/typedapi/types/enums/sortorder" |
|
|
|
|
"github.com/elastic/go-elasticsearch/v8/typedapi/types/enums/textquerytype" |
|
|
|
|
"os" |
|
|
|
|
|
|
|
|
|
"github.com/coze-dev/coze-studio/backend/infra/contract/es" |
|
|
|
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv" |
|
|
|
@ -51,7 +51,7 @@ type es8BulkIndexer struct { |
|
|
|
|
type es8Types struct{} |
|
|
|
|
|
|
|
|
|
func newES8() (Client, error) { |
|
|
|
|
addresses, err := parsex.ParseClusterEndpoints(os.Getenv("ES_ADDR")) |
|
|
|
|
addresses, err := parseClusterEndpoints(os.Getenv("ES_ADDR")) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
@ -243,8 +243,8 @@ func (c *es8Client) CreateIndex(ctx context.Context, index string, properties ma |
|
|
|
|
Properties: propertiesMap, |
|
|
|
|
}, |
|
|
|
|
Settings: &types.IndexSettings{ |
|
|
|
|
NumberOfShards: parsex.GetEnvDefaultIntSetting("ES_NUMBER_OF_SHARDS", "1"), |
|
|
|
|
NumberOfReplicas: parsex.GetEnvDefaultIntSetting("ES_NUMBER_OF_REPLICAS", "1"), |
|
|
|
|
NumberOfShards: getEnvDefaultIntSetting("ES_NUMBER_OF_SHARDS", "1"), |
|
|
|
|
NumberOfReplicas: getEnvDefaultIntSetting("ES_NUMBER_OF_REPLICAS", "1"), |
|
|
|
|
}, |
|
|
|
|
}).Do(ctx); err != nil { |
|
|
|
|
return err |
|
|
|
|