fix index delete on search api (#353)

This commit is contained in:
Dominic Wong
2022-01-17 11:43:27 +00:00
committed by GitHub
parent 6a7d7db044
commit ce21c31088

View File

@@ -143,7 +143,7 @@ func (s *Search) Index(ctx context.Context, request *pb.IndexRequest, response *
request.Document.Id = uuid.New().String()
}
if len(request.Index) == 0 {
return errors.BadRequest(method, "Missing index_name param")
return errors.BadRequest(method, "Missing index param")
}
if !isValidIndexName(request.Index) {
return errors.BadRequest(method, "Index name should contain only alphanumerics and hyphens")
@@ -181,6 +181,9 @@ func (s *Search) Delete(ctx context.Context, request *pb.DeleteRequest, response
if !ok {
return errors.Unauthorized(method, "Unauthorized")
}
if len(request.Index) == 0 {
return errors.BadRequest(method, "Missing index param")
}
req := openapi.DeleteRequest{
Index: indexName(tnt, request.Index),
DocumentID: request.Id,
@@ -274,8 +277,11 @@ func (s *Search) DeleteIndex(ctx context.Context, request *pb.DeleteIndexRequest
if !ok {
return errors.Unauthorized(method, "Unauthorized")
}
req := openapi.DeleteRequest{
Index: indexName(tnt, request.Index),
if len(request.Index) == 0 {
return errors.BadRequest(method, "Missing index param")
}
req := openapi.IndicesDeleteRequest{
Index: []string{indexName(tnt, request.Index)},
}
rsp, err := req.Do(ctx, s.client)
if err != nil {