Fix text index existence error messages

This commit is contained in:
Ante Pušić 2024-02-18 18:20:06 +01:00
parent 00bdd8ac96
commit d7fc3bb65a
2 changed files with 7 additions and 2 deletions

View File

@ -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) {

View File

@ -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 \"{}\" doesnt exist.", index_name);
}
try {
mgcxx::text_search::drop_index(index_name);