diff --git a/README.md b/README.md index 188563d..9e0fde5 100644 --- a/README.md +++ b/README.md @@ -149,70 +149,70 @@ This endpoint returns the latest cluster status. ```json { "indexer_assignment": { - "example_en": { - "shard-Dyb1CXqJ": "node-YA0Zso3w", - "shard-OSFMC5gL": "node-YA0Zso3w", - "shard-TQu8fyHA": "node-YA0Zso3w", - "shard-UfilJ5I4": "node-YA0Zso3w", - "shard-WLJEezNT": "node-YA0Zso3w", - "shard-eH6LOGpc": "node-YA0Zso3w", - "shard-jWU7v3MR": "node-YA0Zso3w", - "shard-sng0xmKr": "node-YA0Zso3w", - "shard-tKKy1LdN": "node-YA0Zso3w", - "shard-vpI7ExL5": "node-YA0Zso3w" + "wikipedia_en": { + "shard-73iAEf8K": "node-duIMwfjn", + "shard-CRzZVi2b": "node-duIMwfjn", + "shard-Wh7VO5Lp": "node-duIMwfjn", + "shard-YazeIhze": "node-duIMwfjn", + "shard-cXyt4esz": "node-duIMwfjn", + "shard-hUM3HWQW": "node-duIMwfjn", + "shard-jH3sTtc7": "node-duIMwfjn", + "shard-viI2Dm3V": "node-duIMwfjn", + "shard-y1tMwCEP": "node-duIMwfjn", + "shard-y7VRCIlU": "node-duIMwfjn" } }, "indexes": { - "example_en": { - "index_lock_uri": "etcd://phalanx/locks/example_en", - "index_uri": "minio://phalanx/indexes/example_en", + "wikipedia_en": { + "index_lock_uri": "", + "index_uri": "file:///tmp/phalanx/indexes/wikipedia_en", "shards": { - "shard-Dyb1CXqJ": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-Dyb1CXqJ", - "shard_uri": "minio://phalanx/indexes/example_en/shard-Dyb1CXqJ" + "shard-73iAEf8K": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-73iAEf8K" }, - "shard-OSFMC5gL": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-OSFMC5gL", - "shard_uri": "minio://phalanx/indexes/example_en/shard-OSFMC5gL" + "shard-CRzZVi2b": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-CRzZVi2b" }, - "shard-TQu8fyHA": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-TQu8fyHA", - "shard_uri": "minio://phalanx/indexes/example_en/shard-TQu8fyHA" + "shard-Wh7VO5Lp": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-Wh7VO5Lp" }, - "shard-UfilJ5I4": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-UfilJ5I4", - "shard_uri": "minio://phalanx/indexes/example_en/shard-UfilJ5I4" + "shard-YazeIhze": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-YazeIhze" }, - "shard-WLJEezNT": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-WLJEezNT", - "shard_uri": "minio://phalanx/indexes/example_en/shard-WLJEezNT" + "shard-cXyt4esz": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-cXyt4esz" }, - "shard-eH6LOGpc": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-eH6LOGpc", - "shard_uri": "minio://phalanx/indexes/example_en/shard-eH6LOGpc" + "shard-hUM3HWQW": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-hUM3HWQW" }, - "shard-jWU7v3MR": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-jWU7v3MR", - "shard_uri": "minio://phalanx/indexes/example_en/shard-jWU7v3MR" + "shard-jH3sTtc7": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-jH3sTtc7" }, - "shard-sng0xmKr": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-sng0xmKr", - "shard_uri": "minio://phalanx/indexes/example_en/shard-sng0xmKr" + "shard-viI2Dm3V": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-viI2Dm3V" }, - "shard-tKKy1LdN": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-tKKy1LdN", - "shard_uri": "minio://phalanx/indexes/example_en/shard-tKKy1LdN" + "shard-y1tMwCEP": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-y1tMwCEP" }, - "shard-vpI7ExL5": { - "shard_lock_uri": "etcd://phalanx/locks/example_en/shard-vpI7ExL5", - "shard_uri": "minio://phalanx/indexes/example_en/shard-vpI7ExL5" + "shard-y7VRCIlU": { + "shard_lock_uri": "", + "shard_uri": "file:///tmp/phalanx/indexes/wikipedia_en/shard-y7VRCIlU" } } } }, "nodes": { - "node-YA0Zso3w": { - "addr": "172.19.0.4", + "node-duIMwfjn": { + "addr": "0.0.0.0", "meta": { "grpc_port": 5000, "http_port": 8000, @@ -221,41 +221,41 @@ This endpoint returns the latest cluster status. "searcher" ] }, - "port": 2000, + "port": 3000, "state": "alive" } }, "searcher_assignment": { - "example_en": { - "shard-Dyb1CXqJ": [ - "node-YA0Zso3w" + "wikipedia_en": { + "shard-73iAEf8K": [ + "node-duIMwfjn" ], - "shard-OSFMC5gL": [ - "node-YA0Zso3w" + "shard-CRzZVi2b": [ + "node-duIMwfjn" ], - "shard-TQu8fyHA": [ - "node-YA0Zso3w" + "shard-Wh7VO5Lp": [ + "node-duIMwfjn" ], - "shard-UfilJ5I4": [ - "node-YA0Zso3w" + "shard-YazeIhze": [ + "node-duIMwfjn" ], - "shard-WLJEezNT": [ - "node-YA0Zso3w" + "shard-cXyt4esz": [ + "node-duIMwfjn" ], - "shard-eH6LOGpc": [ - "node-YA0Zso3w" + "shard-hUM3HWQW": [ + "node-duIMwfjn" ], - "shard-jWU7v3MR": [ - "node-YA0Zso3w" + "shard-jH3sTtc7": [ + "node-duIMwfjn" ], - "shard-sng0xmKr": [ - "node-YA0Zso3w" + "shard-viI2Dm3V": [ + "node-duIMwfjn" ], - "shard-tKKy1LdN": [ - "node-YA0Zso3w" + "shard-y1tMwCEP": [ + "node-duIMwfjn" ], - "shard-vpI7ExL5": [ - "node-YA0Zso3w" + "shard-y7VRCIlU": [ + "node-duIMwfjn" ] } } @@ -283,6 +283,85 @@ This endpoint returns the latest cluster status. % curl -XPOST -H 'Content-type: text/plain' http://localhost:8000/v1/indexes/wikipedia_en/_search --data-binary @./examples/search.json | jq . ``` +```json +{ + "documents": [ + { + "_id": "1316", + "_score": 4.09425168678948, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 1316, + "title": "Annales school" + }, + { + "_id": "1164", + "_score": 3.8142450139472404, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 1164, + "title": "Artificial intelligence" + }, + { + "_id": "1902", + "_score": 3.485971543579737, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 1902, + "title": "American Airlines Flight 77" + }, + { + "_id": "1397", + "_score": 3.4334036711733162, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 1397, + "title": "AOL" + }, + { + "_id": "775", + "_score": 3.410320998122167, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 775, + "title": "Algorithm" + }, + { + "_id": "1074", + "_score": 3.054015403581521, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 1074, + "title": "Royal Antigua and Barbuda Defence Force" + }, + { + "_id": "1361", + "_score": 2.8482692170070774, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 1361, + "title": "Anagram" + }, + { + "_id": "1805", + "_score": 2.783279368389514, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 1805, + "title": "Antibiotic" + }, + { + "_id": "1924", + "_score": 2.7722489839906252, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 1924, + "title": "Argo Navis" + }, + { + "_id": "1274", + "_score": 2.7359659717085734, + "_timestamp": "2022-01-02T12:46:13Z", + "id": 1274, + "title": "Geography of Antarctica" + } + ], + "hits": 59, + "index_name": "wikipedia_en" +} +``` + ## Delete index diff --git a/bin/phalanx_docs.sh b/bin/phalanx_docs.sh index 5e09b01..fb03a76 100755 --- a/bin/phalanx_docs.sh +++ b/bin/phalanx_docs.sh @@ -66,4 +66,4 @@ if [ -p /dev/stdin ]; then cat - else cat ${FILENAME} -fi | jq -c -r '.'${ID_FIELD}' as $id | {"id": $id | tostring, "fields": .}' +fi | jq -c -r '.'${ID_FIELD}' as $id | . |= .+ {"_id": $id | tostring}' diff --git a/cluster/cluster.go b/cluster/cluster.go index 8a8a55c..6fd919b 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -57,6 +57,8 @@ func NewCluster(host string, bindPort int, nodeMetadata NodeMetadata, isSeedNode // } // members.UpdateNode(10 * time.Second) + fmt.Println("cluster created", memberList.LocalNode().Name) + return &Cluster{ memberList: memberList, nodeEventDeliegate: nodeEventDeliegate, diff --git a/cmd/phalanx.go b/cmd/phalanx.go index e1408cd..7dcd832 100644 --- a/cmd/phalanx.go +++ b/cmd/phalanx.go @@ -26,7 +26,7 @@ const defaultEnvFile string = ".env" const defaultConfigFile string = "" const defaultHost string = "0.0.0.0" -const defaultBindPort int = 3000 +const defaultBindPort int = 2000 const defaultGrpcPort int = 5000 const defaultHttpPort int = 8000 diff --git a/examples/create_index_example_en.json b/examples/create_index_example_en.json index 9ce9e82..39f57a5 100644 --- a/examples/create_index_example_en.json +++ b/examples/create_index_example_en.json @@ -205,5 +205,6 @@ } } }, - "num_shards": 10 + "num_shards": 10, + "default_search_field": "_all" } diff --git a/examples/create_index_wikipedia_en.json b/examples/create_index_wikipedia_en.json index dcd9370..b155d8a 100644 --- a/examples/create_index_wikipedia_en.json +++ b/examples/create_index_wikipedia_en.json @@ -173,5 +173,6 @@ } } }, - "num_shards": 10 + "num_shards": 10, + "default_search_field": "_all" } diff --git a/examples/create_index_wikipedia_en_local.json b/examples/create_index_wikipedia_en_local.json index 99f0a82..7f2d515 100644 --- a/examples/create_index_wikipedia_en_local.json +++ b/examples/create_index_wikipedia_en_local.json @@ -172,5 +172,6 @@ } } }, - "num_shards": 10 + "num_shards": 10, + "default_search_field": "_all" } diff --git a/examples/create_index_wikipedia_ja.json b/examples/create_index_wikipedia_ja.json index 9eebbe8..9e4d7da 100644 --- a/examples/create_index_wikipedia_ja.json +++ b/examples/create_index_wikipedia_ja.json @@ -207,5 +207,6 @@ } } }, - "num_shards": 10 + "num_shards": 10, + "default_search_field": "_all" } diff --git a/examples/create_index_wikipedia_ja_local.json b/examples/create_index_wikipedia_ja_local.json index 59b4ff2..752fa18 100644 --- a/examples/create_index_wikipedia_ja_local.json +++ b/examples/create_index_wikipedia_ja_local.json @@ -206,5 +206,6 @@ } } }, - "num_shards": 10 + "num_shards": 10, + "default_search_field": "_all" } diff --git a/examples/search.json b/examples/search.json index e44b9c5..a29232c 100644 --- a/examples/search.json +++ b/examples/search.json @@ -1,8 +1,11 @@ { - "index_name": "wikipedia_en", "query": "search", - "field": "text", "boost": 1.0, "start": 0, - "num": 10 + "num": 5, + "sort_by": "-_score", + "fields": [ + "id", + "title" + ] } diff --git a/index/reader.go b/index/reader.go index fab1e81..6d04b36 100644 --- a/index/reader.go +++ b/index/reader.go @@ -7,6 +7,7 @@ import ( "github.com/blugelabs/bluge" "github.com/mosuka/phalanx/directory" "github.com/mosuka/phalanx/errors" + "github.com/mosuka/phalanx/mapping" "github.com/mosuka/phalanx/metastore" "go.uber.org/zap" ) @@ -110,6 +111,8 @@ func (i *IndexReaders) open(indexName string, shardName string, indexMetadata *m } if indexMetadata.DefaultSearchField != "" { config.DefaultSearchField = indexMetadata.DefaultSearchField + } else { + config.DefaultSearchField = mapping.AllFieldName } // config.DefaultSearchAnalyzer = req.DefaultSearchAnalyzer // config.DefaultSimilarity = req.DefaultSearchSimilarity diff --git a/index/writer.go b/index/writer.go index 2c49012..f242d6d 100644 --- a/index/writer.go +++ b/index/writer.go @@ -7,6 +7,7 @@ import ( "github.com/blugelabs/bluge" "github.com/mosuka/phalanx/directory" "github.com/mosuka/phalanx/errors" + "github.com/mosuka/phalanx/mapping" "github.com/mosuka/phalanx/metastore" "go.uber.org/zap" ) @@ -90,6 +91,8 @@ func (i *IndexWriters) open(indexName string, shardName string, indexMetadata *m } if indexMetadata.DefaultSearchField != "" { config.DefaultSearchField = indexMetadata.DefaultSearchField + } else { + config.DefaultSearchField = mapping.AllFieldName } // config.DefaultSearchAnalyzer = req.DefaultSearchAnalyzer // config.DefaultSimilarity = req.DefaultSearchSimilarity diff --git a/mapping/mapping.go b/mapping/mapping.go index 2960260..4ac44cf 100644 --- a/mapping/mapping.go +++ b/mapping/mapping.go @@ -25,6 +25,7 @@ import ( const IdFieldName = "_id" const TimestampFieldName = "_timestamp" +const ScoreFieldName = "_score" const AllFieldName = "_all" const DefaultTextFieldOptions = bluge.Index | bluge.Store | bluge.SearchTermPositions | bluge.HighlightMatches @@ -396,7 +397,7 @@ func (m IndexMapping) GetAnalyzer(fieldName string) (*analysis.Analyzer, error) charFilter := char.NewZeroWidthNonJoinerCharFilter() charFilters = append(charFilters, charFilter) default: - err := fmt.Errorf("unknown char filter: %s\n", charFilterSetting.Name) + err := fmt.Errorf("unknown char filter: %s", charFilterSetting.Name) return nil, err } } @@ -442,7 +443,7 @@ func (m IndexMapping) GetAnalyzer(fieldName string) (*analysis.Analyzer, error) case "symbol": rune = unicode.IsSymbol default: - err := fmt.Errorf("unknown rune option: %s\n", runeStr) + err := fmt.Errorf("unknown rune option: %s", runeStr) return nil, err } fieldTokenizer = tokenizer.NewCharacterTokenizer(rune) @@ -550,7 +551,7 @@ func (m IndexMapping) GetAnalyzer(fieldName string) (*analysis.Analyzer, error) for _, stopTag := range stopTags { token, ok := stopTag.(string) if !ok { - return nil, fmt.Errorf("stop_tag is unexpected: %v\n", stopTag) + return nil, fmt.Errorf("stop_tag is unexpected: %v", stopTag) } stopTagsTokenMap.AddToken(token) } @@ -567,7 +568,7 @@ func (m IndexMapping) GetAnalyzer(fieldName string) (*analysis.Analyzer, error) for _, baseForm := range baseForms { token, ok := baseForm.(string) if !ok { - return nil, fmt.Errorf("stop_tag is unexpected: %v\n", baseForm) + return nil, fmt.Errorf("stop_tag is unexpected: %v", baseForm) } baseFormsTokenMap.AddToken(token) } @@ -618,7 +619,7 @@ func (m IndexMapping) GetAnalyzer(fieldName string) (*analysis.Analyzer, error) // } fieldTokenizer = tokenizer.NewWhitespaceTokenizer() default: - err := fmt.Errorf("unknown tokenizer: %s\n", tokenizerSetting.Name) + err := fmt.Errorf("unknown tokenizer: %s", tokenizerSetting.Name) return nil, err } @@ -1004,7 +1005,7 @@ func (m IndexMapping) GetAnalyzer(fieldName string) (*analysis.Analyzer, error) for _, stopToken := range stopTokens { token, ok := stopToken.(string) if !ok { - return nil, fmt.Errorf("base_form is unexpected: %v\n", stopToken) + return nil, fmt.Errorf("base_form is unexpected: %v", stopToken) } stopTokenMap.AddToken(token) } @@ -1067,7 +1068,7 @@ func (m IndexMapping) GetAnalyzer(fieldName string) (*analysis.Analyzer, error) tokenFilter := token.NewUniqueTermFilter() tokenFilters = append(tokenFilters, tokenFilter) default: - err := fmt.Errorf("unknown token filter: %s\n", tokenFilterSetting.Name) + err := fmt.Errorf("unknown token filter: %s", tokenFilterSetting.Name) return nil, err } } @@ -1079,7 +1080,12 @@ func (m IndexMapping) GetAnalyzer(fieldName string) (*analysis.Analyzer, error) }, nil } -func (m IndexMapping) MakeDocument(id string, fieldMap map[string]interface{}) (*bluge.Document, error) { +func (m IndexMapping) MakeDocument(fieldMap map[string]interface{}) (*bluge.Document, error) { + id, ok := fieldMap[IdFieldName].(string) + if !ok { + return nil, errors.ErrDocumentIdDoesNotExist + } + // Create document. doc := bluge.NewDocument(id) diff --git a/proto/index.pb.go b/proto/index.pb.go index d1b562f..f9e8e76 100644 --- a/proto/index.pb.go +++ b/proto/index.pb.go @@ -843,11 +843,12 @@ type CreateIndexRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IndexName string `protobuf:"bytes,1,opt,name=index_name,proto3" json:"index_name,omitempty"` - IndexUri string `protobuf:"bytes,2,opt,name=index_uri,proto3" json:"index_uri,omitempty"` - LockUri string `protobuf:"bytes,3,opt,name=lock_uri,proto3" json:"lock_uri,omitempty"` - IndexMapping []byte `protobuf:"bytes,4,opt,name=index_mapping,proto3" json:"index_mapping,omitempty"` - NumShards uint32 `protobuf:"varint,5,opt,name=num_shards,proto3" json:"num_shards,omitempty"` + IndexName string `protobuf:"bytes,1,opt,name=index_name,proto3" json:"index_name,omitempty"` + IndexUri string `protobuf:"bytes,2,opt,name=index_uri,proto3" json:"index_uri,omitempty"` + LockUri string `protobuf:"bytes,3,opt,name=lock_uri,proto3" json:"lock_uri,omitempty"` + IndexMapping []byte `protobuf:"bytes,4,opt,name=index_mapping,proto3" json:"index_mapping,omitempty"` + NumShards uint32 `protobuf:"varint,5,opt,name=num_shards,proto3" json:"num_shards,omitempty"` + DefaultSearchField string `protobuf:"bytes,6,opt,name=default_search_field,proto3" json:"default_search_field,omitempty"` } func (x *CreateIndexRequest) Reset() { @@ -917,6 +918,13 @@ func (x *CreateIndexRequest) GetNumShards() uint32 { return 0 } +func (x *CreateIndexRequest) GetDefaultSearchField() string { + if x != nil { + return x.DefaultSearchField + } + return "" +} + type CreateIndexResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1040,176 +1048,20 @@ func (*DeleteIndexResponse) Descriptor() ([]byte, []int) { return file_proto_index_proto_rawDescGZIP(), []int{15} } -type Document struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Fields []byte `protobuf:"bytes,2,opt,name=fields,proto3" json:"fields,omitempty"` - Score float64 `protobuf:"fixed64,3,opt,name=score,proto3" json:"score,omitempty"` -} - -func (x *Document) Reset() { - *x = Document{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_index_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Document) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Document) ProtoMessage() {} - -func (x *Document) ProtoReflect() protoreflect.Message { - mi := &file_proto_index_proto_msgTypes[16] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Document.ProtoReflect.Descriptor instead. -func (*Document) Descriptor() ([]byte, []int) { - return file_proto_index_proto_rawDescGZIP(), []int{16} -} - -func (x *Document) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *Document) GetFields() []byte { - if x != nil { - return x.Fields - } - return nil -} - -func (x *Document) GetScore() float64 { - if x != nil { - return x.Score - } - return 0 -} - -type AddDocumentRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - IndexName string `protobuf:"bytes,1,opt,name=index_name,proto3" json:"index_name,omitempty"` - Document *Document `protobuf:"bytes,2,opt,name=document,proto3" json:"document,omitempty"` -} - -func (x *AddDocumentRequest) Reset() { - *x = AddDocumentRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_index_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AddDocumentRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddDocumentRequest) ProtoMessage() {} - -func (x *AddDocumentRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_index_proto_msgTypes[17] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AddDocumentRequest.ProtoReflect.Descriptor instead. -func (*AddDocumentRequest) Descriptor() ([]byte, []int) { - return file_proto_index_proto_rawDescGZIP(), []int{17} -} - -func (x *AddDocumentRequest) GetIndexName() string { - if x != nil { - return x.IndexName - } - return "" -} - -func (x *AddDocumentRequest) GetDocument() *Document { - if x != nil { - return x.Document - } - return nil -} - -type AddDocumentResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *AddDocumentResponse) Reset() { - *x = AddDocumentResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_index_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AddDocumentResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddDocumentResponse) ProtoMessage() {} - -func (x *AddDocumentResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_index_proto_msgTypes[18] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AddDocumentResponse.ProtoReflect.Descriptor instead. -func (*AddDocumentResponse) Descriptor() ([]byte, []int) { - return file_proto_index_proto_rawDescGZIP(), []int{18} -} - type AddDocumentsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IndexName string `protobuf:"bytes,1,opt,name=index_name,proto3" json:"index_name,omitempty"` - ShardName string `protobuf:"bytes,2,opt,name=shard_name,proto3" json:"shard_name,omitempty"` - Documents []*Document `protobuf:"bytes,3,rep,name=documents,proto3" json:"documents,omitempty"` + IndexName string `protobuf:"bytes,1,opt,name=index_name,proto3" json:"index_name,omitempty"` + ShardName string `protobuf:"bytes,2,opt,name=shard_name,proto3" json:"shard_name,omitempty"` + Documents [][]byte `protobuf:"bytes,3,rep,name=documents,proto3" json:"documents,omitempty"` } func (x *AddDocumentsRequest) Reset() { *x = AddDocumentsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_index_proto_msgTypes[19] + mi := &file_proto_index_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1222,7 +1074,7 @@ func (x *AddDocumentsRequest) String() string { func (*AddDocumentsRequest) ProtoMessage() {} func (x *AddDocumentsRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_index_proto_msgTypes[19] + mi := &file_proto_index_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1235,7 +1087,7 @@ func (x *AddDocumentsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AddDocumentsRequest.ProtoReflect.Descriptor instead. func (*AddDocumentsRequest) Descriptor() ([]byte, []int) { - return file_proto_index_proto_rawDescGZIP(), []int{19} + return file_proto_index_proto_rawDescGZIP(), []int{16} } func (x *AddDocumentsRequest) GetIndexName() string { @@ -1252,7 +1104,7 @@ func (x *AddDocumentsRequest) GetShardName() string { return "" } -func (x *AddDocumentsRequest) GetDocuments() []*Document { +func (x *AddDocumentsRequest) GetDocuments() [][]byte { if x != nil { return x.Documents } @@ -1268,7 +1120,7 @@ type AddDocumentsResponse struct { func (x *AddDocumentsResponse) Reset() { *x = AddDocumentsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_index_proto_msgTypes[20] + mi := &file_proto_index_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1281,7 +1133,7 @@ func (x *AddDocumentsResponse) String() string { func (*AddDocumentsResponse) ProtoMessage() {} func (x *AddDocumentsResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_index_proto_msgTypes[20] + mi := &file_proto_index_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1294,7 +1146,7 @@ func (x *AddDocumentsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AddDocumentsResponse.ProtoReflect.Descriptor instead. func (*AddDocumentsResponse) Descriptor() ([]byte, []int) { - return file_proto_index_proto_rawDescGZIP(), []int{20} + return file_proto_index_proto_rawDescGZIP(), []int{17} } type DeleteDocumentsRequest struct { @@ -1310,7 +1162,7 @@ type DeleteDocumentsRequest struct { func (x *DeleteDocumentsRequest) Reset() { *x = DeleteDocumentsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_index_proto_msgTypes[21] + mi := &file_proto_index_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1323,7 +1175,7 @@ func (x *DeleteDocumentsRequest) String() string { func (*DeleteDocumentsRequest) ProtoMessage() {} func (x *DeleteDocumentsRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_index_proto_msgTypes[21] + mi := &file_proto_index_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1336,7 +1188,7 @@ func (x *DeleteDocumentsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteDocumentsRequest.ProtoReflect.Descriptor instead. func (*DeleteDocumentsRequest) Descriptor() ([]byte, []int) { - return file_proto_index_proto_rawDescGZIP(), []int{21} + return file_proto_index_proto_rawDescGZIP(), []int{18} } func (x *DeleteDocumentsRequest) GetIndexName() string { @@ -1369,7 +1221,7 @@ type DeleteDocumentsResponse struct { func (x *DeleteDocumentsResponse) Reset() { *x = DeleteDocumentsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_index_proto_msgTypes[22] + mi := &file_proto_index_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1382,7 +1234,7 @@ func (x *DeleteDocumentsResponse) String() string { func (*DeleteDocumentsResponse) ProtoMessage() {} func (x *DeleteDocumentsResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_index_proto_msgTypes[22] + mi := &file_proto_index_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1395,7 +1247,7 @@ func (x *DeleteDocumentsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteDocumentsResponse.ProtoReflect.Descriptor instead. func (*DeleteDocumentsResponse) Descriptor() ([]byte, []int) { - return file_proto_index_proto_rawDescGZIP(), []int{22} + return file_proto_index_proto_rawDescGZIP(), []int{19} } type SearchRequest struct { @@ -1406,16 +1258,17 @@ type SearchRequest struct { IndexName string `protobuf:"bytes,1,opt,name=index_name,proto3" json:"index_name,omitempty"` ShardNames []string `protobuf:"bytes,2,rep,name=shard_names,proto3" json:"shard_names,omitempty"` Query string `protobuf:"bytes,3,opt,name=query,proto3" json:"query,omitempty"` - Field string `protobuf:"bytes,4,opt,name=field,proto3" json:"field,omitempty"` - Boost float64 `protobuf:"fixed64,5,opt,name=boost,proto3" json:"boost,omitempty"` - Start int32 `protobuf:"varint,6,opt,name=start,proto3" json:"start,omitempty"` - Num int32 `protobuf:"varint,7,opt,name=num,proto3" json:"num,omitempty"` + Boost float64 `protobuf:"fixed64,4,opt,name=boost,proto3" json:"boost,omitempty"` + Start int32 `protobuf:"varint,5,opt,name=start,proto3" json:"start,omitempty"` + Num int32 `protobuf:"varint,6,opt,name=num,proto3" json:"num,omitempty"` + SortBy string `protobuf:"bytes,7,opt,name=sort_by,proto3" json:"sort_by,omitempty"` + Fields []string `protobuf:"bytes,8,rep,name=fields,proto3" json:"fields,omitempty"` } func (x *SearchRequest) Reset() { *x = SearchRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_index_proto_msgTypes[23] + mi := &file_proto_index_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1428,7 +1281,7 @@ func (x *SearchRequest) String() string { func (*SearchRequest) ProtoMessage() {} func (x *SearchRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_index_proto_msgTypes[23] + mi := &file_proto_index_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1441,7 +1294,7 @@ func (x *SearchRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SearchRequest.ProtoReflect.Descriptor instead. func (*SearchRequest) Descriptor() ([]byte, []int) { - return file_proto_index_proto_rawDescGZIP(), []int{23} + return file_proto_index_proto_rawDescGZIP(), []int{20} } func (x *SearchRequest) GetIndexName() string { @@ -1465,13 +1318,6 @@ func (x *SearchRequest) GetQuery() string { return "" } -func (x *SearchRequest) GetField() string { - if x != nil { - return x.Field - } - return "" -} - func (x *SearchRequest) GetBoost() float64 { if x != nil { return x.Boost @@ -1493,20 +1339,34 @@ func (x *SearchRequest) GetNum() int32 { return 0 } +func (x *SearchRequest) GetSortBy() string { + if x != nil { + return x.SortBy + } + return "" +} + +func (x *SearchRequest) GetFields() []string { + if x != nil { + return x.Fields + } + return nil +} + type SearchResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IndexName string `protobuf:"bytes,1,opt,name=index_name,proto3" json:"index_name,omitempty"` - Hits uint64 `protobuf:"varint,2,opt,name=hits,proto3" json:"hits,omitempty"` - Documents []*Document `protobuf:"bytes,3,rep,name=documents,proto3" json:"documents,omitempty"` + IndexName string `protobuf:"bytes,1,opt,name=index_name,proto3" json:"index_name,omitempty"` + Hits uint64 `protobuf:"varint,2,opt,name=hits,proto3" json:"hits,omitempty"` + Documents [][]byte `protobuf:"bytes,3,rep,name=documents,proto3" json:"documents,omitempty"` } func (x *SearchResponse) Reset() { *x = SearchResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_index_proto_msgTypes[24] + mi := &file_proto_index_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1519,7 +1379,7 @@ func (x *SearchResponse) String() string { func (*SearchResponse) ProtoMessage() {} func (x *SearchResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_index_proto_msgTypes[24] + mi := &file_proto_index_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1532,7 +1392,7 @@ func (x *SearchResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead. func (*SearchResponse) Descriptor() ([]byte, []int) { - return file_proto_index_proto_rawDescGZIP(), []int{24} + return file_proto_index_proto_rawDescGZIP(), []int{21} } func (x *SearchResponse) GetIndexName() string { @@ -1549,7 +1409,7 @@ func (x *SearchResponse) GetHits() uint64 { return 0 } -func (x *SearchResponse) GetDocuments() []*Document { +func (x *SearchResponse) GetDocuments() [][]byte { if x != nil { return x.Documents } @@ -1635,7 +1495,7 @@ var file_proto_index_proto_rawDesc = []byte{ 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xb4, 0x01, 0x0a, 0x12, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xe8, 0x01, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, @@ -1647,131 +1507,122 @@ var file_proto_index_proto_rawDesc = []byte{ 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, 0x6e, 0x75, 0x6d, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x64, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6e, 0x75, 0x6d, 0x5f, 0x73, 0x68, 0x61, 0x72, - 0x64, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, - 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x34, 0x0a, 0x12, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x22, - 0x15, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x48, 0x0a, 0x08, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, - 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, - 0x22, 0x61, 0x0a, 0x12, 0x41, 0x64, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, - 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, - 0x65, 0x6e, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x84, 0x01, 0x0a, 0x13, 0x41, - 0x64, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x6f, - 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x22, 0x16, 0x0a, 0x14, 0x41, 0x64, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6a, 0x0a, 0x16, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x64, 0x73, 0x12, 0x32, 0x0a, 0x14, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x14, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, + 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x34, 0x0a, + 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x03, 0x69, 0x64, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, - 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0xbb, 0x01, 0x0a, 0x0d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, - 0x65, 0x6c, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, - 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6f, 0x6f, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, - 0x05, 0x62, 0x6f, 0x6f, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x10, 0x0a, 0x03, - 0x6e, 0x75, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6e, 0x75, 0x6d, 0x22, 0x73, - 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x61, 0x6d, 0x65, 0x22, 0x15, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x64, + 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x73, 0x0a, 0x13, 0x41, 0x64, + 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, + 0x16, 0x0a, 0x14, 0x41, 0x64, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6a, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, + 0x69, 0x64, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x6f, 0x63, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xd7, + 0x01, 0x0a, 0x0d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x68, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, - 0x68, 0x69, 0x74, 0x73, 0x12, 0x2d, 0x0a, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, - 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x2a, 0x5e, 0x0a, 0x0d, 0x4c, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x73, 0x73, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x4c, 0x49, 0x56, 0x45, 0x4e, 0x45, 0x53, 0x53, - 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, - 0x12, 0x18, 0x0a, 0x14, 0x4c, 0x49, 0x56, 0x45, 0x4e, 0x45, 0x53, 0x53, 0x5f, 0x53, 0x54, 0x41, - 0x54, 0x45, 0x5f, 0x41, 0x4c, 0x49, 0x56, 0x45, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x49, - 0x56, 0x45, 0x4e, 0x45, 0x53, 0x53, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x44, 0x45, 0x41, - 0x44, 0x10, 0x02, 0x2a, 0x67, 0x0a, 0x0e, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x65, 0x73, 0x73, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1b, 0x0a, 0x17, 0x52, 0x45, 0x41, 0x44, 0x49, 0x4e, 0x45, - 0x53, 0x53, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, - 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x52, 0x45, 0x41, 0x44, 0x49, 0x4e, 0x45, 0x53, 0x53, 0x5f, - 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x52, 0x45, 0x41, 0x44, 0x59, 0x10, 0x01, 0x12, 0x1d, 0x0a, - 0x19, 0x52, 0x45, 0x41, 0x44, 0x49, 0x4e, 0x45, 0x53, 0x53, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, - 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x52, 0x45, 0x41, 0x44, 0x59, 0x10, 0x02, 0x2a, 0x50, 0x0a, 0x08, - 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x4e, 0x4f, 0x44, 0x45, - 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, - 0x15, 0x0a, 0x11, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x49, 0x4e, 0x44, - 0x45, 0x58, 0x45, 0x52, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x52, - 0x4f, 0x4c, 0x45, 0x5f, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, 0x45, 0x52, 0x10, 0x02, 0x2a, 0x7b, - 0x0a, 0x09, 0x4e, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x4e, - 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, - 0x4e, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, - 0x45, 0x5f, 0x41, 0x4c, 0x49, 0x56, 0x45, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4e, 0x4f, 0x44, - 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x55, 0x53, 0x50, 0x45, 0x43, 0x54, 0x10, - 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, - 0x44, 0x45, 0x41, 0x44, 0x10, 0x03, 0x12, 0x13, 0x0a, 0x0f, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x53, - 0x54, 0x41, 0x54, 0x45, 0x5f, 0x4c, 0x45, 0x46, 0x54, 0x10, 0x04, 0x32, 0x86, 0x05, 0x0a, 0x05, - 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x4c, 0x0a, 0x0d, 0x4c, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x73, - 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x1b, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x4c, - 0x69, 0x76, 0x65, 0x6e, 0x65, 0x73, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x4c, 0x69, 0x76, 0x65, - 0x6e, 0x65, 0x73, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x0e, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x65, 0x73, 0x73, - 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x1c, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x52, 0x65, - 0x61, 0x64, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x52, 0x65, 0x61, 0x64, - 0x69, 0x6e, 0x65, 0x73, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x07, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, - 0x15, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x4d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x3a, 0x0a, 0x07, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x69, 0x6e, - 0x64, 0x65, 0x78, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x0b, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x19, 0x2e, 0x69, 0x6e, - 0x64, 0x65, 0x78, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, - 0x64, 0x65, 0x78, 0x12, 0x19, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, - 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x64, - 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x0c, - 0x41, 0x64, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1a, 0x2e, 0x69, - 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x41, 0x64, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, - 0x2e, 0x41, 0x64, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x2e, 0x69, 0x6e, 0x64, - 0x65, 0x78, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x06, 0x53, - 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x14, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x53, 0x65, - 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x69, 0x6e, - 0x64, 0x65, 0x78, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x73, 0x75, 0x6b, 0x61, 0x2f, 0x70, 0x68, 0x61, 0x6c, 0x61, 0x6e, - 0x78, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6f, 0x6f, 0x73, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x62, 0x6f, 0x6f, 0x73, 0x74, 0x12, 0x14, + 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x75, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x03, 0x6e, 0x75, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x62, + 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x62, 0x79, + 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0x62, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x69, + 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x68, 0x69, 0x74, 0x73, 0x12, 0x1c, + 0x0a, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0c, 0x52, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2a, 0x5e, 0x0a, 0x0d, + 0x4c, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x73, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1a, 0x0a, + 0x16, 0x4c, 0x49, 0x56, 0x45, 0x4e, 0x45, 0x53, 0x53, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, + 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, 0x4c, 0x49, 0x56, + 0x45, 0x4e, 0x45, 0x53, 0x53, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x41, 0x4c, 0x49, 0x56, + 0x45, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x49, 0x56, 0x45, 0x4e, 0x45, 0x53, 0x53, 0x5f, + 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x44, 0x45, 0x41, 0x44, 0x10, 0x02, 0x2a, 0x67, 0x0a, 0x0e, + 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1b, + 0x0a, 0x17, 0x52, 0x45, 0x41, 0x44, 0x49, 0x4e, 0x45, 0x53, 0x53, 0x5f, 0x53, 0x54, 0x41, 0x54, + 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x52, + 0x45, 0x41, 0x44, 0x49, 0x4e, 0x45, 0x53, 0x53, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x52, + 0x45, 0x41, 0x44, 0x59, 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x52, 0x45, 0x41, 0x44, 0x49, 0x4e, + 0x45, 0x53, 0x53, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x52, 0x45, + 0x41, 0x44, 0x59, 0x10, 0x02, 0x2a, 0x50, 0x0a, 0x08, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x6f, 0x6c, + 0x65, 0x12, 0x15, 0x0a, 0x11, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x55, + 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x4e, 0x4f, 0x44, 0x45, + 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x49, 0x4e, 0x44, 0x45, 0x58, 0x45, 0x52, 0x10, 0x01, 0x12, + 0x16, 0x0a, 0x12, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x53, 0x45, 0x41, + 0x52, 0x43, 0x48, 0x45, 0x52, 0x10, 0x02, 0x2a, 0x7b, 0x0a, 0x09, 0x4e, 0x6f, 0x64, 0x65, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, + 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, + 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x41, 0x4c, 0x49, 0x56, 0x45, + 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, + 0x5f, 0x53, 0x55, 0x53, 0x50, 0x45, 0x43, 0x54, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x4e, 0x4f, + 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x44, 0x45, 0x41, 0x44, 0x10, 0x03, 0x12, + 0x13, 0x0a, 0x0f, 0x4e, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x4c, 0x45, + 0x46, 0x54, 0x10, 0x04, 0x32, 0x86, 0x05, 0x0a, 0x05, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x4c, + 0x0a, 0x0d, 0x4c, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x73, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, + 0x1b, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x4c, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x73, 0x73, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x4c, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x73, 0x73, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x0e, + 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x1c, + 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x65, 0x73, 0x73, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, + 0x07, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x15, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x07, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x12, 0x19, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1a, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, + 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x19, 0x2e, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x0c, 0x41, 0x64, 0x64, 0x44, 0x6f, 0x63, 0x75, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1a, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x41, 0x64, + 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1b, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x41, 0x64, 0x64, 0x44, 0x6f, 0x63, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x52, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x14, + 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x53, 0x65, 0x61, + 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x21, 0x5a, + 0x1f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x73, 0x75, + 0x6b, 0x61, 0x2f, 0x70, 0x68, 0x61, 0x6c, 0x61, 0x6e, 0x78, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1787,7 +1638,7 @@ func file_proto_index_proto_rawDescGZIP() []byte { } var file_proto_index_proto_enumTypes = make([]protoimpl.EnumInfo, 4) -var file_proto_index_proto_msgTypes = make([]protoimpl.MessageInfo, 28) +var file_proto_index_proto_msgTypes = make([]protoimpl.MessageInfo, 25) var file_proto_index_proto_goTypes = []interface{}{ (LivenessState)(0), // 0: index.LivenessState (ReadinessState)(0), // 1: index.ReadinessState @@ -1809,18 +1660,15 @@ var file_proto_index_proto_goTypes = []interface{}{ (*CreateIndexResponse)(nil), // 17: index.CreateIndexResponse (*DeleteIndexRequest)(nil), // 18: index.DeleteIndexRequest (*DeleteIndexResponse)(nil), // 19: index.DeleteIndexResponse - (*Document)(nil), // 20: index.Document - (*AddDocumentRequest)(nil), // 21: index.AddDocumentRequest - (*AddDocumentResponse)(nil), // 22: index.AddDocumentResponse - (*AddDocumentsRequest)(nil), // 23: index.AddDocumentsRequest - (*AddDocumentsResponse)(nil), // 24: index.AddDocumentsResponse - (*DeleteDocumentsRequest)(nil), // 25: index.DeleteDocumentsRequest - (*DeleteDocumentsResponse)(nil), // 26: index.DeleteDocumentsResponse - (*SearchRequest)(nil), // 27: index.SearchRequest - (*SearchResponse)(nil), // 28: index.SearchResponse - nil, // 29: index.IndexMetadata.ShardsEntry - nil, // 30: index.ClusterResponse.NodesEntry - nil, // 31: index.ClusterResponse.IndexesEntry + (*AddDocumentsRequest)(nil), // 20: index.AddDocumentsRequest + (*AddDocumentsResponse)(nil), // 21: index.AddDocumentsResponse + (*DeleteDocumentsRequest)(nil), // 22: index.DeleteDocumentsRequest + (*DeleteDocumentsResponse)(nil), // 23: index.DeleteDocumentsResponse + (*SearchRequest)(nil), // 24: index.SearchRequest + (*SearchResponse)(nil), // 25: index.SearchResponse + nil, // 26: index.IndexMetadata.ShardsEntry + nil, // 27: index.ClusterResponse.NodesEntry + nil, // 28: index.ClusterResponse.IndexesEntry } var file_proto_index_proto_depIdxs = []int32{ 0, // 0: index.LivenessCheckResponse.state:type_name -> index.LivenessState @@ -1828,38 +1676,35 @@ var file_proto_index_proto_depIdxs = []int32{ 2, // 2: index.NodeMeta.roles:type_name -> index.NodeRole 10, // 3: index.Node.meta:type_name -> index.NodeMeta 3, // 4: index.Node.state:type_name -> index.NodeState - 29, // 5: index.IndexMetadata.shards:type_name -> index.IndexMetadata.ShardsEntry - 30, // 6: index.ClusterResponse.nodes:type_name -> index.ClusterResponse.NodesEntry - 31, // 7: index.ClusterResponse.indexes:type_name -> index.ClusterResponse.IndexesEntry - 20, // 8: index.AddDocumentRequest.document:type_name -> index.Document - 20, // 9: index.AddDocumentsRequest.documents:type_name -> index.Document - 20, // 10: index.SearchResponse.documents:type_name -> index.Document - 12, // 11: index.IndexMetadata.ShardsEntry.value:type_name -> index.ShardMetadata - 11, // 12: index.ClusterResponse.NodesEntry.value:type_name -> index.Node - 13, // 13: index.ClusterResponse.IndexesEntry.value:type_name -> index.IndexMetadata - 4, // 14: index.Index.LivenessCheck:input_type -> index.LivenessCheckRequest - 6, // 15: index.Index.ReadinessCheck:input_type -> index.ReadinessCheckRequest - 8, // 16: index.Index.Metrics:input_type -> index.MetricsRequest - 14, // 17: index.Index.Cluster:input_type -> index.ClusterRequest - 16, // 18: index.Index.CreateIndex:input_type -> index.CreateIndexRequest - 18, // 19: index.Index.DeleteIndex:input_type -> index.DeleteIndexRequest - 23, // 20: index.Index.AddDocuments:input_type -> index.AddDocumentsRequest - 25, // 21: index.Index.DeleteDocuments:input_type -> index.DeleteDocumentsRequest - 27, // 22: index.Index.Search:input_type -> index.SearchRequest - 5, // 23: index.Index.LivenessCheck:output_type -> index.LivenessCheckResponse - 7, // 24: index.Index.ReadinessCheck:output_type -> index.ReadinessCheckResponse - 9, // 25: index.Index.Metrics:output_type -> index.MetricsResponse - 15, // 26: index.Index.Cluster:output_type -> index.ClusterResponse - 17, // 27: index.Index.CreateIndex:output_type -> index.CreateIndexResponse - 19, // 28: index.Index.DeleteIndex:output_type -> index.DeleteIndexResponse - 24, // 29: index.Index.AddDocuments:output_type -> index.AddDocumentsResponse - 26, // 30: index.Index.DeleteDocuments:output_type -> index.DeleteDocumentsResponse - 28, // 31: index.Index.Search:output_type -> index.SearchResponse - 23, // [23:32] is the sub-list for method output_type - 14, // [14:23] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 26, // 5: index.IndexMetadata.shards:type_name -> index.IndexMetadata.ShardsEntry + 27, // 6: index.ClusterResponse.nodes:type_name -> index.ClusterResponse.NodesEntry + 28, // 7: index.ClusterResponse.indexes:type_name -> index.ClusterResponse.IndexesEntry + 12, // 8: index.IndexMetadata.ShardsEntry.value:type_name -> index.ShardMetadata + 11, // 9: index.ClusterResponse.NodesEntry.value:type_name -> index.Node + 13, // 10: index.ClusterResponse.IndexesEntry.value:type_name -> index.IndexMetadata + 4, // 11: index.Index.LivenessCheck:input_type -> index.LivenessCheckRequest + 6, // 12: index.Index.ReadinessCheck:input_type -> index.ReadinessCheckRequest + 8, // 13: index.Index.Metrics:input_type -> index.MetricsRequest + 14, // 14: index.Index.Cluster:input_type -> index.ClusterRequest + 16, // 15: index.Index.CreateIndex:input_type -> index.CreateIndexRequest + 18, // 16: index.Index.DeleteIndex:input_type -> index.DeleteIndexRequest + 20, // 17: index.Index.AddDocuments:input_type -> index.AddDocumentsRequest + 22, // 18: index.Index.DeleteDocuments:input_type -> index.DeleteDocumentsRequest + 24, // 19: index.Index.Search:input_type -> index.SearchRequest + 5, // 20: index.Index.LivenessCheck:output_type -> index.LivenessCheckResponse + 7, // 21: index.Index.ReadinessCheck:output_type -> index.ReadinessCheckResponse + 9, // 22: index.Index.Metrics:output_type -> index.MetricsResponse + 15, // 23: index.Index.Cluster:output_type -> index.ClusterResponse + 17, // 24: index.Index.CreateIndex:output_type -> index.CreateIndexResponse + 19, // 25: index.Index.DeleteIndex:output_type -> index.DeleteIndexResponse + 21, // 26: index.Index.AddDocuments:output_type -> index.AddDocumentsResponse + 23, // 27: index.Index.DeleteDocuments:output_type -> index.DeleteDocumentsResponse + 25, // 28: index.Index.Search:output_type -> index.SearchResponse + 20, // [20:29] is the sub-list for method output_type + 11, // [11:20] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_proto_index_proto_init() } @@ -2061,42 +1906,6 @@ func file_proto_index_proto_init() { } } file_proto_index_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Document); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_index_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddDocumentRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_index_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddDocumentResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_index_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AddDocumentsRequest); i { case 0: return &v.state @@ -2108,7 +1917,7 @@ func file_proto_index_proto_init() { return nil } } - file_proto_index_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + file_proto_index_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AddDocumentsResponse); i { case 0: return &v.state @@ -2120,7 +1929,7 @@ func file_proto_index_proto_init() { return nil } } - file_proto_index_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + file_proto_index_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeleteDocumentsRequest); i { case 0: return &v.state @@ -2132,7 +1941,7 @@ func file_proto_index_proto_init() { return nil } } - file_proto_index_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + file_proto_index_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeleteDocumentsResponse); i { case 0: return &v.state @@ -2144,7 +1953,7 @@ func file_proto_index_proto_init() { return nil } } - file_proto_index_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + file_proto_index_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SearchRequest); i { case 0: return &v.state @@ -2156,7 +1965,7 @@ func file_proto_index_proto_init() { return nil } } - file_proto_index_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + file_proto_index_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SearchResponse); i { case 0: return &v.state @@ -2175,7 +1984,7 @@ func file_proto_index_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_index_proto_rawDesc, NumEnums: 4, - NumMessages: 28, + NumMessages: 25, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/index.proto b/proto/index.proto index 994e4c7..a4d86d8 100644 --- a/proto/index.proto +++ b/proto/index.proto @@ -107,6 +107,7 @@ message CreateIndexRequest { string lock_uri = 3 [json_name="lock_uri"]; bytes index_mapping = 4 [json_name="index_mapping"]; uint32 num_shards = 5 [json_name="num_shards"]; + string default_search_field = 6 [json_name="default_search_field"]; } message CreateIndexResponse { @@ -119,24 +120,10 @@ message DeleteIndexRequest { message DeleteIndexResponse { } -message Document { - string id = 1; - bytes fields = 2; - double score = 3; -} - -message AddDocumentRequest { - string index_name = 1 [json_name="index_name"]; - Document document = 2; -} - -message AddDocumentResponse { -} - message AddDocumentsRequest { string index_name = 1 [json_name="index_name"]; string shard_name = 2 [json_name="shard_name"]; - repeated Document documents = 3; + repeated bytes documents = 3; } message AddDocumentsResponse { @@ -155,14 +142,15 @@ message SearchRequest { string index_name = 1 [json_name="index_name"]; repeated string shard_names = 2 [json_name="shard_names"]; string query = 3; - string field = 4; - double boost = 5; - int32 start = 6; - int32 num = 7; + double boost = 4; + int32 start = 5; + int32 num = 6; + string sort_by = 7 [json_name="sort_by"]; + repeated string fields = 8; } message SearchResponse { string index_name = 1 [json_name="index_name"]; uint64 hits = 2; - repeated Document documents = 3; + repeated bytes documents = 3; } diff --git a/proto/index_grpc.pb.go b/proto/index_grpc.pb.go index 3eb89f6..09738b8 100644 --- a/proto/index_grpc.pb.go +++ b/proto/index_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.6.1 +// source: proto/index.proto package proto diff --git a/server/http_handler.go b/server/http_handler.go index e7ff503..ffc526f 100644 --- a/server/http_handler.go +++ b/server/http_handler.go @@ -13,7 +13,6 @@ import ( "github.com/gin-gonic/gin" "github.com/mosuka/phalanx/clients" - "github.com/mosuka/phalanx/marshaler" "github.com/mosuka/phalanx/proto" ) @@ -37,19 +36,19 @@ func getClient(c *gin.Context) (*clients.GRPCIndexClient, error) { return client, nil } -func setMarshaler(marshaler *marshaler.Marshaler) gin.HandlerFunc { +func setMarshaler(marshaler *Marshaler) gin.HandlerFunc { return func(c *gin.Context) { c.Set("marshaler", marshaler) c.Next() } } -func getMarshaler(c *gin.Context) (*marshaler.Marshaler, error) { +func getMarshaler(c *gin.Context) (*Marshaler, error) { marshalerIntr, ok := c.Get("marshaler") if !ok { return nil, fmt.Errorf("marshaler does not exist") } - marshaler, ok := marshalerIntr.(*marshaler.Marshaler) + marshaler, ok := marshalerIntr.(*Marshaler) if !ok { return nil, fmt.Errorf("marshaler is not a Marshaler") } @@ -68,14 +67,14 @@ func livez(c *gin.Context) { return } - marshaler, err := getMarshaler(c) + grpcResp, err := client.LivenessCheck(clientCtx, &proto.LivenessCheckRequest{}) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - grpcResp, err := client.LivenessCheck(clientCtx, &proto.LivenessCheckRequest{}) + marshaler, err := getMarshaler(c) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) @@ -103,14 +102,14 @@ func readyz(c *gin.Context) { return } - marshaler, err := getMarshaler(c) + grpcResp, err := client.ReadinessCheck(clientCtx, &proto.ReadinessCheckRequest{}) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - grpcResp, err := client.ReadinessCheck(clientCtx, &proto.ReadinessCheckRequest{}) + marshaler, err := getMarshaler(c) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) @@ -138,13 +137,6 @@ func metrics(c *gin.Context) { return } - marshaler, err := getMarshaler(c) - if err != nil { - resp := gin.H{"error": err.Error()} - c.JSON(http.StatusInternalServerError, resp) - return - } - grpcResp, err := client.Metrics(clientCtx, &proto.MetricsRequest{}) if err != nil { resp := gin.H{"error": err.Error()} @@ -152,14 +144,7 @@ func metrics(c *gin.Context) { return } - respBytes, err := marshaler.Marshal(grpcResp) - if err != nil { - resp := gin.H{"error": err.Error()} - c.JSON(http.StatusInternalServerError, resp) - return - } - - c.Data(http.StatusOK, "text/plain; version=0.0.4", respBytes) + c.Data(http.StatusOK, "text/plain; version=0.0.4", grpcResp.Metrics) } func cluster(c *gin.Context) { @@ -173,14 +158,14 @@ func cluster(c *gin.Context) { return } - marshaler, err := getMarshaler(c) + grpcResp, err := client.Cluster(clientCtx, &proto.ClusterRequest{}) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - grpcResp, err := client.Cluster(clientCtx, &proto.ClusterRequest{}) + marshaler, err := getMarshaler(c) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) @@ -197,24 +182,7 @@ func cluster(c *gin.Context) { c.Data(http.StatusOK, "application/json", respBytes) } -func putIndex(c *gin.Context) { - clientCtx, clientCancel := context.WithTimeout(context.Background(), 3*time.Second) - defer clientCancel() - - client, err := getClient(c) - if err != nil { - resp := gin.H{"error": err.Error()} - c.JSON(http.StatusInternalServerError, resp) - return - } - - marshaler, err := getMarshaler(c) - if err != nil { - resp := gin.H{"error": err.Error()} - c.JSON(http.StatusInternalServerError, resp) - return - } - +func createIndex(c *gin.Context) { body, err := ioutil.ReadAll(c.Request.Body) if err != nil { resp := gin.H{"error": err.Error()} @@ -230,11 +198,11 @@ func putIndex(c *gin.Context) { } req := &proto.CreateIndexRequest{} - req.IndexName = c.Param("index_name") indexUri, ok := reqMap["index_uri"].(string) if !ok { + // index_uri is required. resp := gin.H{"error": "index_uri is required or unexpected data"} c.JSON(http.StatusInternalServerError, resp) return @@ -243,15 +211,14 @@ func putIndex(c *gin.Context) { lockUri, ok := reqMap["lock_uri"].(string) if !ok { - // resp := gin.H{"error": "lock_uri is required or unexpected data"} - // c.JSON(http.StatusInternalServerError, resp) - // return + // lock_uri is optional req.LockUri = "" } req.LockUri = lockUri indexMapping, ok := reqMap["index_mapping"].(map[string]interface{}) if ok { + // Serialize the index_mapping again and set it in the request. indexMappingBytes, err := json.Marshal(indexMapping) if err != nil { resp := gin.H{"error": "index_uri is not specified or is not a string"} @@ -263,11 +230,20 @@ func putIndex(c *gin.Context) { numShards, ok := reqMap["num_shards"].(float64) if !ok { - resp := gin.H{"error": "num_shards is required or unexpected data"} + // If num_shards omitted, the number of shards is set to 1. + numShards = 1 + } + req.NumShards = uint32(numShards) + + clientCtx, clientCancel := context.WithTimeout(context.Background(), 3*time.Second) + defer clientCancel() + + client, err := getClient(c) + if err != nil { + resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - req.NumShards = uint32(numShards) grpcResp, err := client.CreateIndex(clientCtx, req) if err != nil { @@ -276,6 +252,13 @@ func putIndex(c *gin.Context) { return } + marshaler, err := getMarshaler(c) + if err != nil { + resp := gin.H{"error": err.Error()} + c.JSON(http.StatusInternalServerError, resp) + return + } + respBytes, err := marshaler.Marshal(grpcResp) if err != nil { resp := gin.H{"error": err.Error()} @@ -297,16 +280,16 @@ func deleteIndex(c *gin.Context) { return } - marshaler, err := getMarshaler(c) + grpcResp, err := client.DeleteIndex(clientCtx, &proto.DeleteIndexRequest{ + IndexName: c.Param("index_name"), + }) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - grpcResp, err := client.DeleteIndex(clientCtx, &proto.DeleteIndexRequest{ - IndexName: c.Param("index_name"), - }) + marshaler, err := getMarshaler(c) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) @@ -323,7 +306,7 @@ func deleteIndex(c *gin.Context) { c.Data(http.StatusOK, "application/json", respBytes) } -func putDocuments(c *gin.Context) { +func addDocuments(c *gin.Context) { clientCtx, clientCancel := context.WithTimeout(context.Background(), 3*time.Second) defer clientCancel() @@ -334,20 +317,14 @@ func putDocuments(c *gin.Context) { return } - marshaler, err := getMarshaler(c) - if err != nil { - resp := gin.H{"error": err.Error()} - c.JSON(http.StatusInternalServerError, resp) - return - } - req := &proto.AddDocumentsRequest{} req.IndexName = c.Param("index_name") - req.Documents = make([]*proto.Document, 0) + req.Documents = make([][]byte, 0) reader := bufio.NewReader(c.Request.Body) for { finishReading := false + // Read a line from the request body docBytes, err := reader.ReadBytes('\n') if err != nil { if err == io.EOF || err == io.ErrClosedPipe { @@ -359,36 +336,7 @@ func putDocuments(c *gin.Context) { } } if len(docBytes) > 0 { - docMap := make(map[string]interface{}) - if err := json.Unmarshal(docBytes, &docMap); err != nil { - resp := gin.H{"error": err.Error()} - c.JSON(http.StatusInternalServerError, resp) - return - } - id, ok := docMap["id"].(string) - if !ok { - resp := gin.H{"error": "document id does not exist or is not a string"} - c.JSON(http.StatusInternalServerError, resp) - return - } - fields := docMap["fields"].(map[string]interface{}) - if !ok { - resp := gin.H{"error": fmt.Sprintf("id: %s fields do not exist or is not a map[string]interface{}", id)} - c.JSON(http.StatusInternalServerError, resp) - return - } - fieldsBytes, err := json.Marshal(fields) - if err != nil { - resp := gin.H{"error": err.Error()} - c.JSON(http.StatusInternalServerError, resp) - return - } - - doc := &proto.Document{ - Id: id, - Fields: fieldsBytes, - } - req.Documents = append(req.Documents, doc) + req.Documents = append(req.Documents, docBytes) } if finishReading { break @@ -402,6 +350,13 @@ func putDocuments(c *gin.Context) { return } + marshaler, err := getMarshaler(c) + if err != nil { + resp := gin.H{"error": err.Error()} + c.JSON(http.StatusInternalServerError, resp) + return + } + respBytes, err := marshaler.Marshal(grpcResp) if err != nil { resp := gin.H{"error": err.Error()} @@ -416,20 +371,6 @@ func deleteDocuments(c *gin.Context) { clientCtx, clientCancel := context.WithTimeout(context.Background(), 3*time.Second) defer clientCancel() - client, err := getClient(c) - if err != nil { - resp := gin.H{"error": err.Error()} - c.JSON(http.StatusInternalServerError, resp) - return - } - - marshaler, err := getMarshaler(c) - if err != nil { - resp := gin.H{"error": err.Error()} - c.JSON(http.StatusInternalServerError, resp) - return - } - req := &proto.DeleteDocumentsRequest{} req.IndexName = c.Param("index_name") req.Ids = make([]string, 0) @@ -455,41 +396,38 @@ func deleteDocuments(c *gin.Context) { } } - grpcResp, err := client.DeleteDocuments(clientCtx, req) + client, err := getClient(c) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - respBytes, err := marshaler.Marshal(grpcResp) + grpcResp, err := client.DeleteDocuments(clientCtx, req) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - c.Data(http.StatusOK, "application/json", respBytes) -} - -func search(c *gin.Context) { - clientCtx, clientCancel := context.WithTimeout(context.Background(), 3*time.Second) - defer clientCancel() - - client, err := getClient(c) + marshaler, err := getMarshaler(c) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - marshaler, err := getMarshaler(c) + respBytes, err := marshaler.Marshal(grpcResp) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } + c.Data(http.StatusOK, "application/json", respBytes) +} + +func search(c *gin.Context) { body, err := ioutil.ReadAll(c.Request.Body) if err != nil { resp := gin.H{"error": err.Error()} @@ -497,57 +435,34 @@ func search(c *gin.Context) { return } - var reqMap map[string]interface{} - if err := json.Unmarshal(body, &reqMap); err != nil { + req := &proto.SearchRequest{} + if err := json.Unmarshal(body, req); err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - req := &proto.SearchRequest{} + // Override with the index name specified by the URI. req.IndexName = c.Param("index_name") - query, ok := reqMap["query"].(string) - if !ok { - resp := gin.H{"error": "query does not exist or is not a string"} - c.JSON(http.StatusInternalServerError, resp) - return - } - req.Query = query - - field, ok := reqMap["field"].(string) - if !ok { - resp := gin.H{"error": "field does not exist or is not a string"} - c.JSON(http.StatusInternalServerError, resp) - return - } - req.Field = field - - boost, ok := reqMap["boost"].(float64) - if !ok { - resp := gin.H{"error": "boost does not exist or is not a number"} - c.JSON(http.StatusInternalServerError, resp) - return - } - req.Boost = boost + clientCtx, clientCancel := context.WithTimeout(context.Background(), 3*time.Second) + defer clientCancel() - start, ok := reqMap["start"].(float64) - if !ok { - resp := gin.H{"error": "start does not exist or is not a number"} + client, err := getClient(c) + if err != nil { + resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - req.Start = int32(start) - num, ok := reqMap["num"].(float64) - if !ok { - resp := gin.H{"error": "start does not exist or is not a number"} + grpcResp, err := client.Search(clientCtx, req) + if err != nil { + resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) return } - req.Num = int32(num) - grpcResp, err := client.Search(clientCtx, req) + marshaler, err := getMarshaler(c) if err != nil { resp := gin.H{"error": err.Error()} c.JSON(http.StatusInternalServerError, resp) diff --git a/server/http_server.go b/server/http_server.go index 56d68ce..82296d9 100644 --- a/server/http_server.go +++ b/server/http_server.go @@ -10,7 +10,6 @@ import ( ginzap "github.com/gin-contrib/zap" "github.com/gin-gonic/gin" "github.com/mosuka/phalanx/clients" - "github.com/mosuka/phalanx/marshaler" "go.uber.org/zap" ) @@ -45,7 +44,7 @@ func NewHTTPIndexServerWithTLS(httpAddress string, grpcAddress string, certifica return nil, err } - marshaler := marshaler.NewMarshaler() + marshaler := NewMarshaler() ctx, cancel := context.WithCancel(context.Background()) @@ -68,9 +67,9 @@ func NewHTTPIndexServerWithTLS(httpAddress string, grpcAddress string, certifica router.GET("/readyz", readyz) router.GET("/metrics", metrics) router.GET("/cluster", cluster) - router.PUT("/v1/indexes/:index_name", putIndex) + router.PUT("/v1/indexes/:index_name", createIndex) router.DELETE("/v1/indexes/:index_name", deleteIndex) - router.PUT("/v1/indexes/:index_name/documents", putDocuments) + router.PUT("/v1/indexes/:index_name/documents", addDocuments) router.DELETE("/v1/indexes/:index_name/documents", deleteDocuments) router.POST("/v1/indexes/:index_name/_search", search) diff --git a/server/index_service.go b/server/index_service.go index 7c219f0..5d91e76 100644 --- a/server/index_service.go +++ b/server/index_service.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "math/rand" + "strings" "sync" "time" @@ -506,6 +507,7 @@ func (s *IndexService) CreateIndex(req *proto.CreateIndexRequest) (*proto.Create IndexLockUri: req.LockUri, IndexMapping: indexMapping, IndexMappingVersion: time.Now().UTC().UnixNano(), + DefaultSearchField: req.DefaultSearchField, ShardMetadataMap: make(map[string]*phalanxmetastore.ShardMetadata), } @@ -603,16 +605,27 @@ func (s *IndexService) AddDocuments(req *proto.AddDocumentsRequest) (*proto.AddD // Assign documents. addDocumentsRequests := make(map[string]*proto.AddDocumentsRequest) if isRootRequest { - for _, document := range req.Documents { - shardName := s.metastore.GetResponsibleShard(req.IndexName, document.Id) + for _, docBytes := range req.Documents { + var doc map[string]interface{} + if err := json.Unmarshal(docBytes, &doc); err != nil { + return nil, err + } + + // Get document ID + docID, ok := doc[mapping.IdFieldName].(string) + if !ok { + return nil, errors.ErrDocumentIdDoesNotExist + } + + shardName := s.metastore.GetResponsibleShard(req.IndexName, docID) if _, ok := addDocumentsRequests[shardName]; !ok { addDocumentsRequests[shardName] = &proto.AddDocumentsRequest{ IndexName: req.IndexName, ShardName: shardName, - Documents: make([]*proto.Document, 0), + Documents: make([][]byte, 0), } } - addDocumentsRequests[shardName].Documents = append(addDocumentsRequests[shardName].Documents, document) + addDocumentsRequests[shardName].Documents = append(addDocumentsRequests[shardName].Documents, docBytes) } } else { addDocumentsRequests[req.ShardName] = req @@ -651,28 +664,30 @@ func (s *IndexService) AddDocuments(req *proto.AddDocumentsRequest) (*proto.AddD // Make batch. batch := bluge.NewBatch() - for _, document := range request.Documents { + for _, docBytes := range request.Documents { // Convert JSON string to map. - var fieldMap map[string]interface{} - if err := json.Unmarshal(document.Fields, &fieldMap); err != nil { + var doc map[string]interface{} + if err := json.Unmarshal(docBytes, &doc); err != nil { err := errors.ErrInvalidDocument s.logger.Error(err.Error()) return err } + // Get mapping. indexMapping, err := s.metastore.GetMapping(request.IndexName) if err != nil { s.logger.Error(err.Error(), zap.String("index_name", request.IndexName)) return err } - // Create document. - doc, err := indexMapping.MakeDocument(document.Id, fieldMap) + + // Create bluge document. + blugeDoc, err := indexMapping.MakeDocument(doc) if err != nil { - s.logger.Error(err.Error(), zap.String("index_name", request.IndexName), zap.String("shard_name", request.ShardName), zap.String("doc_id", document.Id)) + s.logger.Error(err.Error(), zap.String("index_name", request.IndexName), zap.String("shard_name", request.ShardName), zap.Any("doc", doc)) return err } - batch.Update(bluge.Identifier(document.Id), doc) + batch.Update(blugeDoc.ID(), blugeDoc) } // Get index writer. @@ -1007,7 +1022,7 @@ func (s *IndexService) Search(req *proto.SearchRequest) (*proto.SearchResponse, if nodeName == s.cluster.LocalNodeName() { resp := &proto.SearchResponse{ IndexName: request.IndexName, - Documents: make([]*proto.Document, 0), + Documents: make([][]byte, 0), Hits: 0, } @@ -1051,6 +1066,7 @@ func (s *IndexService) Search(req *proto.SearchRequest) (*proto.SearchResponse, query := bluge.NewBooleanQuery().AddMust(userQuery) // TODO: add filter queries // .AddMust(filters...) + if request.Boost > 0.0 { query.SetBoost(request.Boost) } @@ -1059,6 +1075,13 @@ func (s *IndexService) Search(req *proto.SearchRequest) (*proto.SearchResponse, SetFrom(int(request.Start)). WithStandardAggregations(). ExplainScores() + + if request.SortBy != "" { + blugeRequest.SortBy([]string{request.SortBy}) + } else { + blugeRequest.SortBy([]string{"-_score"}) + } + // TODO: add aggretations // request.AddAggregation(name, aggregation) @@ -1106,49 +1129,56 @@ func (s *IndexService) Search(req *proto.SearchRequest) (*proto.SearchResponse, // Make docs for err == nil && docMatch != nil { - doc := &proto.Document{} - - // Load stored fields. - // TODO: Filter only the fields that are needed. - fields := make(map[string]interface{}) + // Load stored doc. + // TODO: Filter only the doc that are needed. + doc := make(map[string]interface{}) err := docMatch.VisitStoredFields(func(field string, value []byte) bool { switch field { case mapping.IdFieldName: - doc.Id = string(value) + doc[field] = string(value) case mapping.TimestampFieldName: timestamp, err := bluge.DecodeDateTime(value) if err != nil { s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.Any("field", field)) } - fields[field] = timestamp.Format(time.RFC3339) + doc[field] = timestamp.Format(time.RFC3339) default: - // decode field value - fieldType, err := indexMapping.GetFieldType(field) - if err != nil { - s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.String("field_name", field)) - return true + exists := false + for _, fieldName := range request.Fields { + if fieldName == field { + exists = true + break + } } - switch fieldType { - case mapping.TextField: - fields[field] = string(value) - case mapping.NumericField: - f64Value, err := bluge.DecodeNumericFloat64(value) + if exists { + // decode field value + fieldType, err := indexMapping.GetFieldType(field) if err != nil { - s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.Any("field", field)) + s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.String("field_name", field)) + return true } - fields[field] = f64Value - case mapping.DatetimeField: - timestamp, err := bluge.DecodeDateTime(value) - if err != nil { - s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.Any("field", field)) + switch fieldType { + case mapping.TextField: + doc[field] = string(value) + case mapping.NumericField: + f64Value, err := bluge.DecodeNumericFloat64(value) + if err != nil { + s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.Any("field", field)) + } + doc[field] = f64Value + case mapping.DatetimeField: + timestamp, err := bluge.DecodeDateTime(value) + if err != nil { + s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.Any("field", field)) + } + doc[field] = timestamp.Format(time.RFC3339) + case mapping.GeoPointField: + lat, lon, err := bluge.DecodeGeoLonLat(value) + if err != nil { + s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.Any("field", field)) + } + doc[field] = geo.Point{Lat: lat, Lon: lon} } - fields[field] = timestamp.Format(time.RFC3339) - case mapping.GeoPointField: - lat, lon, err := bluge.DecodeGeoLonLat(value) - if err != nil { - s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.Any("field", field)) - } - fields[field] = geo.Point{Lat: lat, Lon: lon} } } return true @@ -1165,10 +1195,13 @@ func (s *IndexService) Search(req *proto.SearchRequest) (*proto.SearchResponse, return err } - // Set doc fields. - fieldsBytes, err := json.Marshal(fields) + // Set doc score. + doc[mapping.ScoreFieldName] = docMatch.Score + + // Serialize doc. + docBytes, err := json.Marshal(doc) if err != nil { - s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.Any("doc", fields)) + s.logger.Error(err.Error(), zap.String("index_name", req.IndexName), zap.Any("doc", doc)) responsesChan <- searchResponse{ nodeName: nodeName, indexName: request.IndexName, @@ -1178,12 +1211,8 @@ func (s *IndexService) Search(req *proto.SearchRequest) (*proto.SearchResponse, } return err } - doc.Fields = fieldsBytes - - // Set doc score. - doc.Score = docMatch.Score - resp.Documents = append(resp.Documents, doc) + resp.Documents = append(resp.Documents, docBytes) docMatch, err = docMatchIter.Next() if err != nil { @@ -1285,8 +1314,10 @@ func (s *IndexService) Search(req *proto.SearchRequest) (*proto.SearchResponse, close(responsesChan) // Merge responses. + + fmt.Println("merge") resp := &proto.SearchResponse{} - resp.Documents = make([]*proto.Document, 0) + resp.Documents = make([][]byte, 0) resp.IndexName = req.IndexName for response := range responsesChan { if response.err != nil { @@ -1294,7 +1325,7 @@ func (s *IndexService) Search(req *proto.SearchRequest) (*proto.SearchResponse, } resp.Hits = resp.Hits + response.resp.Hits - resp.Documents = mergeDocs(resp.Documents, response.resp.Documents) + resp.Documents = mergeDocs(req.SortBy, resp.Documents, response.resp.Documents) } if int(req.Start+req.Num) > len(resp.Documents) { @@ -1306,7 +1337,14 @@ func (s *IndexService) Search(req *proto.SearchRequest) (*proto.SearchResponse, return resp, nil } -func mergeDocs(docs1 []*proto.Document, docs2 []*proto.Document) []*proto.Document { +type sortOrder int + +const ( + sortOrderAsc sortOrder = iota + sortOrderDesc +) + +func mergeDocs(sortBy string, docs1 [][]byte, docs2 [][]byte) [][]byte { if len(docs1) == 0 { return docs2 } @@ -1315,15 +1353,48 @@ func mergeDocs(docs1 []*proto.Document, docs2 []*proto.Document) []*proto.Docume return docs1 } - retDocs := make([]*proto.Document, 0) + order := sortOrderAsc + field := sortBy + if strings.HasPrefix(sortBy, "-") { + order = sortOrderDesc + field = sortBy[1:] + } + + retDocs := make([][]byte, 0) for len(docs1) > 0 && len(docs2) > 0 { // Add document with high scores to the list. - var doc *proto.Document - if docs1[0].Score > docs2[0].Score { - doc, docs1 = docs1[0], docs1[1:] + doc1 := make(map[string]interface{}) + json.Unmarshal(docs1[0], &doc1) + + doc2 := make(map[string]interface{}) + json.Unmarshal(docs2[0], &doc2) + + // sortValue1 := doc1["_score"].(float64) + // sortValue2 := doc2["_score"].(float64) + sortValue1 := doc1[field].(float64) + sortValue2 := doc2[field].(float64) + + var doc []byte + // if sortValue1 > sortValue2 { + // doc, docs1 = docs1[0], docs1[1:] + // } else { + // doc, docs2 = docs2[0], docs2[1:] + // } + if order == sortOrderDesc { + fmt.Println("desc") + if sortValue1 > sortValue2 { + doc, docs1 = docs1[0], docs1[1:] + } else { + doc, docs2 = docs2[0], docs2[1:] + } } else { - doc, docs2 = docs2[0], docs2[1:] + fmt.Println("asc") + if sortValue1 < sortValue2 { + doc, docs1 = docs1[0], docs1[1:] + } else { + doc, docs2 = docs2[0], docs2[1:] + } } retDocs = append(retDocs, doc) } diff --git a/marshaler/marshaler.go b/server/marshaler.go similarity index 82% rename from marshaler/marshaler.go rename to server/marshaler.go index 66da977..cc4f461 100644 --- a/marshaler/marshaler.go +++ b/server/marshaler.go @@ -1,8 +1,7 @@ -package marshaler +package server import ( "encoding/json" - "fmt" "io" "io/ioutil" @@ -46,8 +45,6 @@ func (m *Marshaler) Marshal(v interface{}) ([]byte, error) { resp["state"] = "unknown" } return json.Marshal(resp) - case *proto.MetricsResponse: - return value.Metrics, nil case *proto.ClusterResponse: resp := make(map[string]interface{}) resp["nodes"] = make(map[string]interface{}) @@ -117,19 +114,15 @@ func (m *Marshaler) Marshal(v interface{}) ([]byte, error) { resp := make(map[string]interface{}) resp["index_name"] = value.IndexName resp["hits"] = value.Hits - docSlice := make([]map[string]interface{}, 0) - for _, doc := range value.Documents { - docMap := make(map[string]interface{}) - docMap["id"] = doc.Id - docMap["score"] = doc.Score - var fields map[string]interface{} - if err := json.Unmarshal(doc.Fields, &fields); err != nil { + docs := make([]map[string]interface{}, 0) + for _, docBytes := range value.Documents { + var doc map[string]interface{} + if err := json.Unmarshal(docBytes, &doc); err != nil { return nil, err } - docMap["fields"] = fields - docSlice = append(docSlice, docMap) + docs = append(docs, doc) } - resp["documents"] = docSlice + resp["documents"] = docs return json.Marshal(resp) default: return json.Marshal(value) @@ -166,29 +159,6 @@ func (m *Marshaler) Unmarshal(data []byte, v interface{}) error { value.IndexName = indexName } return nil - case *proto.Document: - var m map[string]interface{} - if err := json.Unmarshal(data, &m); err != nil { - return err - } - id, ok := m["id"].(string) - if !ok { - err := fmt.Errorf("document id does not exit or is not a string") - return err - } - fields := m["fields"].(map[string]interface{}) - if !ok { - err := fmt.Errorf("%s fields do not exist or is not a map[string]interface{}", id) - return err - } - fieldsBytes, err := json.Marshal(fields) - if err != nil { - err := fmt.Errorf("%s failed to marshal fields", id) - return err - } - value.Id = id - value.Fields = fieldsBytes - return nil default: return json.Unmarshal(data, value) }