diff --git a/search/examples.json b/search/examples.json index 39bfcd4..660074e 100644 --- a/search/examples.json +++ b/search/examples.json @@ -91,6 +91,16 @@ "response": {} } ], + "createIndex": [ + { + "title": "Create an index", + "run_check": false, + "request": { + "index": "customers" + }, + "response": {} + } + ], "deleteIndex": [ { "title": "Delete an index", diff --git a/search/handler/search.go b/search/handler/search.go index 216f741..e108ed2 100644 --- a/search/handler/search.go +++ b/search/handler/search.go @@ -107,7 +107,7 @@ func (s *Search) CreateIndex(ctx context.Context, request *pb.CreateIndexRequest if !isValidIndexName(request.Index) { return errors.BadRequest(method, "Index name should contain only alphanumerics and hyphens") } - req := openapi.CreateRequest{ + req := openapi.IndicesCreateRequest{ Index: indexName(tnt, request.Index), 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 { return errors.BadRequest(method, "Error processing document") } - req := openapi.IndexRequest{ + req := openapi.CreateRequest{ Index: indexName(tnt, request.Index), DocumentID: request.Document.Id, Body: bytes.NewBuffer(b), diff --git a/search/proto/search.proto b/search/proto/search.proto index 6450fb3..d28dac2 100644 --- a/search/proto/search.proto +++ b/search/proto/search.proto @@ -7,9 +7,7 @@ package search; option go_package = "./proto;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 Delete(DeleteRequest) returns (DeleteResponse) {} 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 { // the name of the index string index = 1; - repeated Field fields = 2; + // TODO: allow fields to index + // repeated Field fields = 2; } message Field {