aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruitao.liu <ruitao.liu@cloudminds.com>2020-09-10 15:59:16 +0800
committerruitao.liu <ruitao.liu@cloudminds.com>2020-09-10 15:59:16 +0800
commit6a5b38c0d43fd290a85884605a45775c9621ad83 (patch)
tree8e7092e8f40a92841bb11c5213b56cd972364714
parent3f7fbfddca8614fc0d5bb31960993599b5c44bca (diff)
downloadseaweedfs-6a5b38c0d43fd290a85884605a45775c9621ad83.tar.xz
seaweedfs-6a5b38c0d43fd290a85884605a45775c9621ad83.zip
fix elastic kv ops.
-rw-r--r--weed/filer/elastic/v7/elastic_store.go15
-rw-r--r--weed/filer/elastic/v7/elastic_store_kv.go9
2 files changed, 15 insertions, 9 deletions
diff --git a/weed/filer/elastic/v7/elastic_store.go b/weed/filer/elastic/v7/elastic_store.go
index f720fdea0..f1c35f7c6 100644
--- a/weed/filer/elastic/v7/elastic_store.go
+++ b/weed/filer/elastic/v7/elastic_store.go
@@ -20,10 +20,15 @@ var (
indexPrefix = ".seaweedfs_"
indexKV = ".seaweedfs_kv_entries"
mappingWithoutQuery = ` {
- "mappings": {
- "enabled": false
- }
-}`
+ "mappings": {
+ "enabled": false,
+ "properties": {
+ "Value":{
+ "type": "binary"
+ }
+ }
+ }
+ }`
)
type ESEntry struct {
@@ -32,7 +37,7 @@ type ESEntry struct {
}
type ESKVEntry struct {
- Value string `json:Value`
+ Value []byte `json:"Value"`
}
func init() {
diff --git a/weed/filer/elastic/v7/elastic_store_kv.go b/weed/filer/elastic/v7/elastic_store_kv.go
index 1b26bdf8e..99c03314e 100644
--- a/weed/filer/elastic/v7/elastic_store_kv.go
+++ b/weed/filer/elastic/v7/elastic_store_kv.go
@@ -3,6 +3,7 @@ package elastic
import (
"context"
"fmt"
+
"github.com/chrislusf/seaweedfs/weed/filer"
"github.com/chrislusf/seaweedfs/weed/glog"
@@ -32,20 +33,20 @@ func (store *ElasticStore) KvGet(ctx context.Context, key []byte) (value []byte,
Id(string(key)).
Do(ctx)
if elastic.IsNotFound(err) {
- return nil, filer.ErrKvNotFound
+ return value, filer.ErrKvNotFound
}
if searchResult != nil && searchResult.Found {
esEntry := &ESKVEntry{}
if err := jsoniter.Unmarshal(searchResult.Source, esEntry); err == nil {
- return []byte(esEntry.Value), nil
+ return esEntry.Value, nil
}
}
glog.Errorf("find key(%s),%v.", string(key), err)
- return nil, filer.ErrKvNotFound
+ return value, filer.ErrKvNotFound
}
func (store *ElasticStore) KvPut(ctx context.Context, key []byte, value []byte) (err error) {
- esEntry := &ESKVEntry{string(value)}
+ esEntry := &ESKVEntry{value}
val, err := jsoniter.Marshal(esEntry)
if err != nil {
glog.Errorf("insert key(%s) %v.", string(key), err)