Connect text search to its query module
This commit is contained in:
parent
6545a741b8
commit
753aebb895
@ -331,8 +331,8 @@ inline bool graph_has_text_index(mgp_graph *graph, const char *index_name) {
|
||||
}
|
||||
|
||||
// TODO antepusic change result type
|
||||
inline bool graph_search_text_index(mgp_graph *graph, const char *index_name) {
|
||||
return MgInvoke<int>(mgp_graph_has_text_index, graph, index_name);
|
||||
inline bool graph_search_text_index(mgp_graph *graph, const char *index_name, const char *search_string) {
|
||||
return MgInvoke<int>(mgp_graph_has_text_index, graph, index_name, search_string);
|
||||
}
|
||||
|
||||
inline mgp_vertices_iterator *graph_iter_vertices(mgp_graph *g, mgp_memory *memory) {
|
||||
|
@ -894,7 +894,8 @@ enum mgp_error mgp_graph_get_vertex_by_id(struct mgp_graph *g, struct mgp_vertex
|
||||
enum mgp_error mgp_graph_has_text_index(mgp_graph *graph, const char *label, int *result);
|
||||
|
||||
// TODO antepusic change result type
|
||||
enum mgp_error mgp_graph_search_text_index(mgp_graph *graph, const char *index_name, int *result);
|
||||
enum mgp_error mgp_graph_search_text_index(mgp_graph *graph, const char *index_name, const char *search_string,
|
||||
int *result);
|
||||
|
||||
/// Creates label index for given label.
|
||||
/// mgp_error::MGP_ERROR_NO_ERROR is always returned.
|
||||
|
@ -24,7 +24,7 @@ void Search(mgp_list *args, mgp_graph *memgraph_graph, mgp_result *result, mgp_m
|
||||
} // namespace TextSearch
|
||||
|
||||
void Search(mgp_list *args, mgp_graph *memgraph_graph, mgp_result *result, mgp_memory *memory) {
|
||||
// CALL text_search.search("Label", "nekiQuery", searchFields, returnFields) RETURN node, score
|
||||
// CALL text_search.search("Label", "someQuery", searchFields, returnFields) RETURN node, score
|
||||
|
||||
mgp::MemoryDispatcherGuard guard{memory};
|
||||
const auto record_factory = mgp::RecordFactory(result);
|
||||
@ -38,7 +38,7 @@ void Search(mgp_list *args, mgp_graph *memgraph_graph, mgp_result *result, mgp_m
|
||||
}
|
||||
|
||||
// 2. Run text search of that index
|
||||
mgp::graph_search_text_index(memgraph_graph, label.data());
|
||||
mgp::graph_search_text_index(memgraph_graph, label.data(), search_string);
|
||||
|
||||
// text_index.search(label, search_string);
|
||||
|
||||
|
@ -555,6 +555,10 @@ class DbAccessor final {
|
||||
|
||||
bool TextIndexExists(std::string index_name) const { return accessor_->TextIndexExists(index_name); }
|
||||
|
||||
mgcxx_mock::text_search::SearchOutput SearchTextIndex(std::string index_name, std::string search_string) const {
|
||||
return accessor_->SearchTextIndex(index_name, search_string);
|
||||
}
|
||||
|
||||
std::optional<storage::LabelIndexStats> GetIndexStats(const storage::LabelId &label) const {
|
||||
return accessor_->GetIndexStats(label);
|
||||
}
|
||||
|
@ -3333,7 +3333,8 @@ mgp_error mgp_graph_has_text_index(mgp_graph *graph, const char *index_name, int
|
||||
});
|
||||
}
|
||||
|
||||
mgp_error mgp_graph_search_text_index(mgp_graph *graph, const char *index_name, int *result) {
|
||||
mgp_error mgp_graph_search_text_index(mgp_graph *graph, const char *index_name, const char *search_string,
|
||||
int *result) {
|
||||
return WrapExceptions([graph, index_name, result]() { *result = 1; });
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,9 @@ class TextIndex {
|
||||
|
||||
bool IndexExists(std::string index_name) { return index_.contains(index_name); }
|
||||
|
||||
mgcxx_mock::text_search::SearchOutput Search(std::string index_name, mgcxx_mock::text_search::SearchInput input) {
|
||||
mgcxx_mock::text_search::SearchOutput Search(std::string index_name, std::string search_string) {
|
||||
// TODO antepusic: Add metadata to the return fields before search
|
||||
auto input = mgcxx_mock::text_search::SearchInput{};
|
||||
return mgcxx_mock::text_search::Mock::search(index_.at(index_name), input);
|
||||
}
|
||||
|
||||
|
@ -216,6 +216,10 @@ class Storage {
|
||||
return storage_->indices_.text_index_->IndexExists(index_name);
|
||||
}
|
||||
|
||||
mgcxx_mock::text_search::SearchOutput SearchTextIndex(std::string index_name, std::string search_string) const {
|
||||
return storage_->indices_.text_index_->Search(index_name, search_string);
|
||||
}
|
||||
|
||||
virtual IndicesInfo ListAllIndices() const = 0;
|
||||
|
||||
virtual ConstraintsInfo ListAllConstraints() const = 0;
|
||||
@ -252,9 +256,8 @@ class Storage {
|
||||
|
||||
std::vector<EdgeTypeId> ListAllPossiblyPresentEdgeTypes() const;
|
||||
|
||||
mgcxx_mock::text_search::SearchOutput TextSearch(std::string index_name,
|
||||
mgcxx_mock::text_search::SearchInput &search_input) const {
|
||||
return storage_->indices_.text_index_->Search(index_name, search_input);
|
||||
mgcxx_mock::text_search::SearchOutput TextSearch(std::string index_name, std::string &search_string) const {
|
||||
return storage_->indices_.text_index_->Search(index_name, search_string);
|
||||
}
|
||||
|
||||
virtual utils::BasicResult<StorageIndexDefinitionError, void> CreateIndex(LabelId label) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user