update
This commit is contained in:
@@ -44,7 +44,7 @@ func NewElastic(endpoints []string, username, password string) (*ES, error) {
|
||||
// "time": time.Now().Unix(),
|
||||
// "date": time.Now(),
|
||||
// }
|
||||
func (es *ES) CreateDocument(index string, id string, doc *interface{}) {
|
||||
func (es *ES) CreateDocument(index string, id string, doc *any) {
|
||||
var buf bytes.Buffer
|
||||
if err := json.NewEncoder(&buf).Encode(doc); err != nil {
|
||||
log.Println("Elastic NewEncoder:", err)
|
||||
@@ -75,7 +75,7 @@ func (es *ES) CreateDocument(index string, id string, doc *interface{}) {
|
||||
// index 如果文档不存在就创建,如果文档存在就更新
|
||||
// update 更新一个文档,如果文档不存在就返回错误
|
||||
// delete 删除一个文档,如果要删除的文档id不存在,就返回错误
|
||||
func (es *ES) Batch(index string, documens []map[string]interface{}, action string) {
|
||||
func (es *ES) Batch(index string, documens []map[string]any, action string) {
|
||||
log.SetFlags(0)
|
||||
|
||||
var (
|
||||
@@ -162,7 +162,7 @@ func (es *ES) Batch(index string, documens []map[string]interface{}, action stri
|
||||
}
|
||||
}
|
||||
|
||||
func (es *ES) Search(index string, query map[string]interface{}) (res *esapi.Response, err error) {
|
||||
func (es *ES) Search(index string, query map[string]any) (res *esapi.Response, err error) {
|
||||
var buf bytes.Buffer
|
||||
if err = json.NewEncoder(&buf).Encode(query); err != nil {
|
||||
return
|
||||
@@ -201,7 +201,7 @@ func (es *ES) Delete(index, idx string) (res *esapi.Response, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (es *ES) DeleteByQuery(index []string, query map[string]interface{}) (res *esapi.Response, err error) {
|
||||
func (es *ES) DeleteByQuery(index []string, query map[string]any) (res *esapi.Response, err error) {
|
||||
var buf bytes.Buffer
|
||||
if err = json.NewEncoder(&buf).Encode(query); err != nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user