diff --git a/src/query/db_accessor.hpp b/src/query/db_accessor.hpp index 2aef3bb1b..bfe19c63d 100644 --- a/src/query/db_accessor.hpp +++ b/src/query/db_accessor.hpp @@ -553,6 +553,8 @@ class DbAccessor final { return accessor_->LabelPropertyIndexExists(label, prop); } + bool TextIndexExists(storage::LabelId label) const { return accessor_->TextIndexExists(label); } + std::optional GetIndexStats(const storage::LabelId &label) const { return accessor_->GetIndexStats(label); } diff --git a/src/storage/v2/indices/text_index.hpp b/src/storage/v2/indices/text_index.hpp index 648d537e6..75e56932d 100644 --- a/src/storage/v2/indices/text_index.hpp +++ b/src/storage/v2/indices/text_index.hpp @@ -46,6 +46,10 @@ class TextIndex { bool IndexExists(LabelId label) { return index_.contains(label); } + mgcxx_mock::text_search::SearchOutput Search(LabelId label, mgcxx_mock::text_search::SearchInput input) { + return mgcxx_mock::text_search::Mock::search(index_.at(label), input); + } + std::vector ListIndices() { std::vector ret; ret.reserve(index_.size()); diff --git a/src/storage/v2/storage.hpp b/src/storage/v2/storage.hpp index 58289f74c..306207ebd 100644 --- a/src/storage/v2/storage.hpp +++ b/src/storage/v2/storage.hpp @@ -28,6 +28,7 @@ #include "storage/v2/durability/wal.hpp" #include "storage/v2/edge_accessor.hpp" #include "storage/v2/indices/indices.hpp" +#include "storage/v2/mgcxx_mock.hpp" #include "storage/v2/mvcc.hpp" #include "storage/v2/replication/enums.hpp" #include "storage/v2/replication/replication_client.hpp" @@ -211,6 +212,8 @@ class Storage { virtual bool LabelPropertyIndexExists(LabelId label, PropertyId property) const = 0; + bool TextIndexExists(LabelId label) const { return storage_->indices_.text_index_->IndexExists(label); } + virtual IndicesInfo ListAllIndices() const = 0; virtual ConstraintsInfo ListAllConstraints() const = 0; @@ -247,6 +250,11 @@ class Storage { std::vector ListAllPossiblyPresentEdgeTypes() const; + mgcxx_mock::text_search::SearchOutput TextSearch(LabelId label, + mgcxx_mock::text_search::SearchInput &search_input) const { + return storage_->indices_.text_index_->Search(label, search_input); + } + virtual utils::BasicResult CreateIndex(LabelId label) = 0; virtual utils::BasicResult CreateIndex(LabelId label, PropertyId property) = 0;