|
@ -78,12 +78,12 @@ func (store *ElasticStore) initialize(options []elastic.ClientOptionFunc) (err e |
|
|
ctx := context.Background() |
|
|
ctx := context.Background() |
|
|
store.client, err = elastic.NewClient(options...) |
|
|
store.client, err = elastic.NewClient(options...) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return fmt.Errorf("init elastic %v.", err) |
|
|
|
|
|
|
|
|
return fmt.Errorf("init elastic %v", err) |
|
|
} |
|
|
} |
|
|
if ok, err := store.client.IndexExists(indexKV).Do(ctx); err == nil && !ok { |
|
|
if ok, err := store.client.IndexExists(indexKV).Do(ctx); err == nil && !ok { |
|
|
_, err = store.client.CreateIndex(indexKV).Body(kvMappings).Do(ctx) |
|
|
_, err = store.client.CreateIndex(indexKV).Body(kvMappings).Do(ctx) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return fmt.Errorf("create index(%s) %v.", indexKV, err) |
|
|
|
|
|
|
|
|
return fmt.Errorf("create index(%s) %v", indexKV, err) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return nil |
|
|
return nil |
|
@ -114,7 +114,7 @@ func (store *ElasticStore) InsertEntry(ctx context.Context, entry *filer.Entry) |
|
|
value, err := jsoniter.Marshal(esEntry) |
|
|
value, err := jsoniter.Marshal(esEntry) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
glog.Errorf("insert entry(%s) %v.", string(entry.FullPath), err) |
|
|
glog.Errorf("insert entry(%s) %v.", string(entry.FullPath), err) |
|
|
return fmt.Errorf("insert entry %v.", err) |
|
|
|
|
|
|
|
|
return fmt.Errorf("insert entry marshal %v", err) |
|
|
} |
|
|
} |
|
|
_, err = store.client.Index(). |
|
|
_, err = store.client.Index(). |
|
|
Index(index). |
|
|
Index(index). |
|
@ -124,7 +124,7 @@ func (store *ElasticStore) InsertEntry(ctx context.Context, entry *filer.Entry) |
|
|
Do(ctx) |
|
|
Do(ctx) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
glog.Errorf("insert entry(%s) %v.", string(entry.FullPath), err) |
|
|
glog.Errorf("insert entry(%s) %v.", string(entry.FullPath), err) |
|
|
return fmt.Errorf("insert entry %v.", err) |
|
|
|
|
|
|
|
|
return fmt.Errorf("insert entry %v", err) |
|
|
} |
|
|
} |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
@ -194,7 +194,7 @@ func (store *ElasticStore) deleteEntry(ctx context.Context, index, id string) (e |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
glog.Errorf("delete entry(index:%s,_id:%s) %v.", index, id, err) |
|
|
glog.Errorf("delete entry(index:%s,_id:%s) %v.", index, id, err) |
|
|
return fmt.Errorf("delete entry %v.", err) |
|
|
|
|
|
|
|
|
return fmt.Errorf("delete entry %v", err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (store *ElasticStore) DeleteFolderChildren(ctx context.Context, fullpath weed_util.FullPath) (err error) { |
|
|
func (store *ElasticStore) DeleteFolderChildren(ctx context.Context, fullpath weed_util.FullPath) (err error) { |
|
|