add createindex for symmetry

This commit is contained in:
Asim Aslam
2022-01-26 19:11:51 +00:00
parent ceb6dd4198
commit 6321db94cf
3 changed files with 16 additions and 7 deletions

View File

@@ -91,6 +91,16 @@
"response": {} "response": {}
} }
], ],
"createIndex": [
{
"title": "Create an index",
"run_check": false,
"request": {
"index": "customers"
},
"response": {}
}
],
"deleteIndex": [ "deleteIndex": [
{ {
"title": "Delete an index", "title": "Delete an index",

View File

@@ -107,7 +107,7 @@ func (s *Search) CreateIndex(ctx context.Context, request *pb.CreateIndexRequest
if !isValidIndexName(request.Index) { if !isValidIndexName(request.Index) {
return errors.BadRequest(method, "Index name should contain only alphanumerics and hyphens") return errors.BadRequest(method, "Index name should contain only alphanumerics and hyphens")
} }
req := openapi.CreateRequest{ req := openapi.IndicesCreateRequest{
Index: indexName(tnt, request.Index), Index: indexName(tnt, request.Index),
Body: nil, // TODO populate with fields and their types Body: nil, // TODO populate with fields and their types
} }
@@ -156,7 +156,7 @@ func (s *Search) Index(ctx context.Context, request *pb.IndexRequest, response *
if err != nil { if err != nil {
return errors.BadRequest(method, "Error processing document") return errors.BadRequest(method, "Error processing document")
} }
req := openapi.IndexRequest{ req := openapi.CreateRequest{
Index: indexName(tnt, request.Index), Index: indexName(tnt, request.Index),
DocumentID: request.Document.Id, DocumentID: request.Document.Id,
Body: bytes.NewBuffer(b), Body: bytes.NewBuffer(b),

View File

@@ -7,9 +7,7 @@ package search;
option go_package = "./proto;search"; option go_package = "./proto;search";
service Search { service Search {
// TODO reinstate when we have a reason for more fine grained control of index creation, for now just rely on lazy creation on first index call rpc CreateIndex(CreateIndexRequest) returns (CreateIndexResponse) {}
// rpc CreateIndex(CreateIndexRequest) returns (CreateIndexResponse) {}
rpc Index(IndexRequest) returns (IndexResponse) {} rpc Index(IndexRequest) returns (IndexResponse) {}
rpc Delete(DeleteRequest) returns (DeleteResponse) {} rpc Delete(DeleteRequest) returns (DeleteResponse) {}
rpc Search(SearchRequest) returns (SearchResponse) {} rpc Search(SearchRequest) returns (SearchResponse) {}
@@ -62,11 +60,12 @@ message SearchResponse {
} }
// Create a search index by specifying which fields are to be queried // Create a search index by name
message CreateIndexRequest { message CreateIndexRequest {
// the name of the index // the name of the index
string index = 1; string index = 1;
repeated Field fields = 2; // TODO: allow fields to index
// repeated Field fields = 2;
} }
message Field { message Field {