From 4bdcb3320e7ffb7dce448bea29904d327cf03a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ante=20Pu=C5=A1i=C4=87?= Date: Tue, 27 Feb 2024 08:08:48 +0100 Subject: [PATCH] Improve SHOW INDEX INFO for text indices --- src/query/interpreter.cpp | 7 ++++--- tests/e2e/text_search/test_text_search.py | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index 565777581..173b8417f 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -3541,7 +3541,7 @@ PreparedQuery PrepareDatabaseInfoQuery(ParsedQuery parsed_query, bool in_explici } MG_ASSERT(current_db.db_acc_, "Database info query expects a current DB"); - MG_ASSERT(current_db.db_transactional_accessor_, "Database ifo query expects a current DB transaction"); + MG_ASSERT(current_db.db_transactional_accessor_, "Database info query expects a current DB transaction"); auto *dba = &*current_db.execution_db_accessor_; auto *info_query = utils::Downcast(parsed_query.query); @@ -3570,8 +3570,9 @@ PreparedQuery PrepareDatabaseInfoQuery(ParsedQuery parsed_query, bool in_explici TypedValue(storage->PropertyToName(item.second)), TypedValue(static_cast(storage_acc->ApproximateVertexCount(item.first, item.second)))}); } - for (const auto &item : info.text_indices) { - results.push_back({TypedValue(text_index_mark), TypedValue(item.first), TypedValue(), TypedValue()}); + for (const auto &[index_name, label] : info.text_indices) { + results.push_back({TypedValue(fmt::format("{} (name: {})", text_index_mark, index_name)), + TypedValue(storage->LabelToName(label)), TypedValue(), TypedValue()}); } std::sort(results.begin(), results.end(), [&label_index_mark](const auto &record_1, const auto &record_2) { const auto type_1 = record_1[0].ValueString(); diff --git a/tests/e2e/text_search/test_text_search.py b/tests/e2e/text_search/test_text_search.py index 7032d1c20..8d538d464 100644 --- a/tests/e2e/text_search/test_text_search.py +++ b/tests/e2e/text_search/test_text_search.py @@ -28,7 +28,9 @@ def test_create_index(memgraph): index_info = memgraph.execute_and_fetch("""SHOW INDEX INFO""") - assert list(index_info) == [{"index type": "text", "label": "exampleIndex", "property": None, "count": None}] + assert list(index_info) == [ + {"index type": "text (name: exampleIndex)", "label": "Document", "property": None, "count": None} + ] def test_drop_index(memgraph):