diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index a923b3c33..289e4ca29 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -2713,7 +2713,6 @@ PreparedQuery PrepareTextIndexQuery(ParsedQuery parsed_query, bool in_explicit_t case TextIndexQuery::Action::CREATE: { index_notification.code = NotificationCode::CREATE_INDEX; index_notification.title = fmt::format("Created text index on label {}.", text_index_query->label_.name); - // TODO: not just storage + invalidate_plan_cache. Need a DB transaction (for replication) handler = [dba, label, index_name, invalidate_plan_cache = std::move(invalidate_plan_cache)](Notification &index_notification) { diff --git a/src/storage/v2/indices/text_index.cpp b/src/storage/v2/indices/text_index.cpp index 0a9b5d6d8..5a5c29ecb 100644 --- a/src/storage/v2/indices/text_index.cpp +++ b/src/storage/v2/indices/text_index.cpp @@ -28,6 +28,10 @@ void TextIndex::CreateEmptyIndex(const std::string &index_name, LabelId label) { throw query::TextSearchDisabledException(); } + if (index_.contains(index_name)) { + throw query::TextSearchException("Text index \"{}\" already exists.", index_name); + } + try { nlohmann::json mappings = {}; mappings["properties"] = {}; @@ -231,7 +235,9 @@ LabelId TextIndex::DropIndex(const std::string &index_name) { throw query::TextSearchDisabledException(); } - // TODO antepusic check if index exists + if (!index_.contains(index_name)) { + throw query::TextSearchException("Text index \"{}\" doesn’t exist.", index_name); + } try { mgcxx::text_search::drop_index(index_name);