Check whether text search is enabled, fix calls accordingly and set default values for the update_text_index parameter
This commit is contained in:
parent
212ed5830f
commit
be561bb5d6
@ -457,26 +457,25 @@ void ProcessNodeRow(memgraph::storage::Storage *store, const std::vector<std::st
|
|||||||
} else {
|
} else {
|
||||||
pv_id = memgraph::storage::PropertyValue(node_id.id);
|
pv_id = memgraph::storage::PropertyValue(node_id.id);
|
||||||
}
|
}
|
||||||
auto old_node_property = node.SetProperty(acc->NameToProperty(field.name), pv_id, false);
|
auto old_node_property = node.SetProperty(acc->NameToProperty(field.name), pv_id);
|
||||||
if (!old_node_property.HasValue()) throw LoadException("Couldn't add property '{}' to the node", field.name);
|
if (!old_node_property.HasValue()) throw LoadException("Couldn't add property '{}' to the node", field.name);
|
||||||
if (!old_node_property->IsNull()) throw LoadException("The property '{}' already exists", field.name);
|
if (!old_node_property->IsNull()) throw LoadException("The property '{}' already exists", field.name);
|
||||||
}
|
}
|
||||||
id = node_id;
|
id = node_id;
|
||||||
} else if (field.type == "LABEL") {
|
} else if (field.type == "LABEL") {
|
||||||
for (const auto &label : memgraph::utils::Split(value, FLAGS_array_delimiter)) {
|
for (const auto &label : memgraph::utils::Split(value, FLAGS_array_delimiter)) {
|
||||||
auto node_label = node.AddLabel(acc->NameToLabel(label), false);
|
auto node_label = node.AddLabel(acc->NameToLabel(label));
|
||||||
if (!node_label.HasValue()) throw LoadException("Couldn't add label '{}' to the node", label);
|
if (!node_label.HasValue()) throw LoadException("Couldn't add label '{}' to the node", label);
|
||||||
if (!*node_label) throw LoadException("The label '{}' already exists", label);
|
if (!*node_label) throw LoadException("The label '{}' already exists", label);
|
||||||
}
|
}
|
||||||
} else if (field.type != "IGNORE") {
|
} else if (field.type != "IGNORE") {
|
||||||
auto old_node_property =
|
auto old_node_property = node.SetProperty(acc->NameToProperty(field.name), StringToValue(value, field.type));
|
||||||
node.SetProperty(acc->NameToProperty(field.name), StringToValue(value, field.type), false);
|
|
||||||
if (!old_node_property.HasValue()) throw LoadException("Couldn't add property '{}' to the node", field.name);
|
if (!old_node_property.HasValue()) throw LoadException("Couldn't add property '{}' to the node", field.name);
|
||||||
if (!old_node_property->IsNull()) throw LoadException("The property '{}' already exists", field.name);
|
if (!old_node_property->IsNull()) throw LoadException("The property '{}' already exists", field.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto &label : additional_labels) {
|
for (const auto &label : additional_labels) {
|
||||||
auto node_label = node.AddLabel(acc->NameToLabel(label), false);
|
auto node_label = node.AddLabel(acc->NameToLabel(label));
|
||||||
if (!node_label.HasValue()) throw LoadException("Couldn't add label '{}' to the node", label);
|
if (!node_label.HasValue()) throw LoadException("Couldn't add label '{}' to the node", label);
|
||||||
if (!*node_label) throw LoadException("The label '{}' already exists", label);
|
if (!*node_label) throw LoadException("The label '{}' already exists", label);
|
||||||
}
|
}
|
||||||
|
@ -115,11 +115,11 @@ class VertexAccessor final {
|
|||||||
|
|
||||||
auto Labels(storage::View view) const { return impl_.Labels(view); }
|
auto Labels(storage::View view) const { return impl_.Labels(view); }
|
||||||
|
|
||||||
storage::Result<bool> AddLabel(storage::LabelId label, bool update_text_index) {
|
storage::Result<bool> AddLabel(storage::LabelId label, bool update_text_index = false) {
|
||||||
return impl_.AddLabel(label, update_text_index);
|
return impl_.AddLabel(label, update_text_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
storage::Result<bool> RemoveLabel(storage::LabelId label, bool update_text_index) {
|
storage::Result<bool> RemoveLabel(storage::LabelId label, bool update_text_index = false) {
|
||||||
return impl_.RemoveLabel(label, update_text_index);
|
return impl_.RemoveLabel(label, update_text_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ class VertexAccessor final {
|
|||||||
return impl_.UpdateProperties(properties, update_text_index);
|
return impl_.UpdateProperties(properties, update_text_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
storage::Result<storage::PropertyValue> RemoveProperty(storage::PropertyId key, bool update_text_index = true) {
|
storage::Result<storage::PropertyValue> RemoveProperty(storage::PropertyId key, bool update_text_index = false) {
|
||||||
return SetProperty(key, storage::PropertyValue(), update_text_index);
|
return SetProperty(key, storage::PropertyValue(), update_text_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,11 +262,11 @@ class SubgraphVertexAccessor final {
|
|||||||
|
|
||||||
auto Labels(storage::View view) const { return impl_.Labels(view); }
|
auto Labels(storage::View view) const { return impl_.Labels(view); }
|
||||||
|
|
||||||
storage::Result<bool> AddLabel(storage::LabelId label, bool update_text_index) {
|
storage::Result<bool> AddLabel(storage::LabelId label, bool update_text_index = false) {
|
||||||
return impl_.AddLabel(label, update_text_index);
|
return impl_.AddLabel(label, update_text_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
storage::Result<bool> RemoveLabel(storage::LabelId label, bool update_text_index) {
|
storage::Result<bool> RemoveLabel(storage::LabelId label, bool update_text_index = false) {
|
||||||
return impl_.RemoveLabel(label, update_text_index);
|
return impl_.RemoveLabel(label, update_text_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2186,6 +2186,9 @@ PreparedQuery PrepareIndexQuery(ParsedQuery parsed_query, bool in_explicit_trans
|
|||||||
if (index_type == IndexQuery::Type::LOOKUP) {
|
if (index_type == IndexQuery::Type::LOOKUP) {
|
||||||
maybe_index_error = properties.empty() ? dba->CreateIndex(label) : dba->CreateIndex(label, properties[0]);
|
maybe_index_error = properties.empty() ? dba->CreateIndex(label) : dba->CreateIndex(label, properties[0]);
|
||||||
} else if (index_type == IndexQuery::Type::TEXT) {
|
} else if (index_type == IndexQuery::Type::TEXT) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
maybe_index_error = dba->CreateTextIndex(index_name, label);
|
maybe_index_error = dba->CreateTextIndex(index_name, label);
|
||||||
}
|
}
|
||||||
utils::OnScopeExit invalidator(invalidate_plan_cache);
|
utils::OnScopeExit invalidator(invalidate_plan_cache);
|
||||||
@ -2213,6 +2216,9 @@ PreparedQuery PrepareIndexQuery(ParsedQuery parsed_query, bool in_explicit_trans
|
|||||||
if (index_type == IndexQuery::Type::LOOKUP) {
|
if (index_type == IndexQuery::Type::LOOKUP) {
|
||||||
maybe_index_error = properties.empty() ? dba->DropIndex(label) : dba->DropIndex(label, properties[0]);
|
maybe_index_error = properties.empty() ? dba->DropIndex(label) : dba->DropIndex(label, properties[0]);
|
||||||
} else if (index_type == IndexQuery::Type::TEXT) {
|
} else if (index_type == IndexQuery::Type::TEXT) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
maybe_index_error = dba->DropTextIndex(index_name);
|
maybe_index_error = dba->DropTextIndex(index_name);
|
||||||
}
|
}
|
||||||
utils::OnScopeExit invalidator(invalidate_plan_cache);
|
utils::OnScopeExit invalidator(invalidate_plan_cache);
|
||||||
|
@ -217,7 +217,7 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info, Frame *fram
|
|||||||
auto new_node = dba.InsertVertex();
|
auto new_node = dba.InsertVertex();
|
||||||
context.execution_stats[ExecutionStats::Key::CREATED_NODES] += 1;
|
context.execution_stats[ExecutionStats::Key::CREATED_NODES] += 1;
|
||||||
for (auto label : node_info.labels) {
|
for (auto label : node_info.labels) {
|
||||||
auto maybe_error = new_node.AddLabel(label, false);
|
auto maybe_error = new_node.AddLabel(label, false); // skip updating text indices until all labels are added
|
||||||
if (maybe_error.HasError()) {
|
if (maybe_error.HasError()) {
|
||||||
switch (maybe_error.GetError()) {
|
switch (maybe_error.GetError()) {
|
||||||
case storage::Error::SERIALIZATION_ERROR:
|
case storage::Error::SERIALIZATION_ERROR:
|
||||||
@ -252,6 +252,7 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info, Frame *fram
|
|||||||
MultiPropsInitChecked(&new_node, properties);
|
MultiPropsInitChecked(&new_node, properties);
|
||||||
|
|
||||||
if (flags::run_time::GetTextSearchEnabled()) {
|
if (flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic cleanup call
|
||||||
new_node.impl_.storage_->indices_.text_index_->AddNode(new_node.impl_.vertex_, new_node.impl_.storage_,
|
new_node.impl_.storage_->indices_.text_index_->AddNode(new_node.impl_.vertex_, new_node.impl_.storage_,
|
||||||
new_node.impl_.transaction_->start_timestamp);
|
new_node.impl_.transaction_->start_timestamp);
|
||||||
}
|
}
|
||||||
@ -2826,6 +2827,7 @@ bool SetProperty::SetPropertyCursor::Pull(Frame &frame, ExecutionContext &contex
|
|||||||
}
|
}
|
||||||
if (flags::run_time::GetTextSearchEnabled()) {
|
if (flags::run_time::GetTextSearchEnabled()) {
|
||||||
auto new_node = lhs.ValueVertex();
|
auto new_node = lhs.ValueVertex();
|
||||||
|
// TODO antepusic cleanup call
|
||||||
new_node.impl_.storage_->indices_.text_index_->UpdateNode(new_node.impl_.vertex_, new_node.impl_.storage_,
|
new_node.impl_.storage_->indices_.text_index_->UpdateNode(new_node.impl_.vertex_, new_node.impl_.storage_,
|
||||||
new_node.impl_.transaction_->start_timestamp);
|
new_node.impl_.transaction_->start_timestamp);
|
||||||
}
|
}
|
||||||
@ -2987,6 +2989,7 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr
|
|||||||
update_props(new_properties);
|
update_props(new_properties);
|
||||||
if (flags::run_time::GetTextSearchEnabled()) {
|
if (flags::run_time::GetTextSearchEnabled()) {
|
||||||
auto new_node = rhs.ValueVertex();
|
auto new_node = rhs.ValueVertex();
|
||||||
|
// TODO antepusic cleanup call
|
||||||
new_node.impl_.storage_->indices_.text_index_->UpdateNode(new_node.impl_.vertex_, new_node.impl_.storage_,
|
new_node.impl_.storage_->indices_.text_index_->UpdateNode(new_node.impl_.vertex_, new_node.impl_.storage_,
|
||||||
new_node.impl_.transaction_->start_timestamp);
|
new_node.impl_.transaction_->start_timestamp);
|
||||||
}
|
}
|
||||||
@ -3117,7 +3120,7 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (auto label : self_.labels_) {
|
for (auto label : self_.labels_) {
|
||||||
auto maybe_value = vertex.AddLabel(label, false);
|
auto maybe_value = vertex.AddLabel(label, false); // skip updating text indices until all labels are added
|
||||||
if (maybe_value.HasError()) {
|
if (maybe_value.HasError()) {
|
||||||
switch (maybe_value.GetError()) {
|
switch (maybe_value.GetError()) {
|
||||||
case storage::Error::SERIALIZATION_ERROR:
|
case storage::Error::SERIALIZATION_ERROR:
|
||||||
@ -3137,6 +3140,7 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags::run_time::GetTextSearchEnabled()) {
|
if (flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic cleanup call
|
||||||
vertex.impl_.storage_->indices_.text_index_->UpdateNode(vertex.impl_.vertex_, vertex.impl_.storage_,
|
vertex.impl_.storage_->indices_.text_index_->UpdateNode(vertex.impl_.vertex_, vertex.impl_.storage_,
|
||||||
vertex.impl_.transaction_->start_timestamp);
|
vertex.impl_.transaction_->start_timestamp);
|
||||||
}
|
}
|
||||||
@ -3212,6 +3216,12 @@ bool RemoveProperty::RemovePropertyCursor::Pull(Frame &frame, ExecutionContext &
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
remove_prop(&lhs.ValueVertex());
|
remove_prop(&lhs.ValueVertex());
|
||||||
|
if (flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic cleanup call
|
||||||
|
auto &updated_node = lhs.ValueVertex();
|
||||||
|
updated_node.impl_.storage_->indices_.text_index_->UpdateNode(
|
||||||
|
updated_node.impl_.vertex_, updated_node.impl_.storage_, updated_node.impl_.transaction_->start_timestamp);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TypedValue::Type::Edge:
|
case TypedValue::Type::Edge:
|
||||||
#ifdef MG_ENTERPRISE
|
#ifdef MG_ENTERPRISE
|
||||||
@ -3303,6 +3313,7 @@ bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, ExecutionContext &cont
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags::run_time::GetTextSearchEnabled()) {
|
if (flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic cleanup call
|
||||||
vertex.impl_.storage_->indices_.text_index_->UpdateNode(vertex.impl_.vertex_, vertex.impl_.storage_,
|
vertex.impl_.storage_->indices_.text_index_->UpdateNode(vertex.impl_.vertex_, vertex.impl_.storage_,
|
||||||
vertex.impl_.transaction_->start_timestamp, self_.labels_);
|
vertex.impl_.transaction_->start_timestamp, self_.labels_);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
|
#include "flags/run_time_configurable.hpp"
|
||||||
#include "license/license.hpp"
|
#include "license/license.hpp"
|
||||||
#include "mg_procedure.h"
|
#include "mg_procedure.h"
|
||||||
#include "module.hpp"
|
#include "module.hpp"
|
||||||
@ -1838,10 +1839,12 @@ mgp_error mgp_vertex_set_property(struct mgp_vertex *v, const char *property_nam
|
|||||||
const auto prop_key =
|
const auto prop_key =
|
||||||
std::visit([property_name](auto *impl) { return impl->NameToProperty(property_name); }, v->graph->impl);
|
std::visit([property_name](auto *impl) { return impl->NameToProperty(property_name); }, v->graph->impl);
|
||||||
|
|
||||||
const auto result =
|
const auto result = std::visit(
|
||||||
std::visit([prop_key, property_value](
|
[prop_key, property_value](auto &impl) {
|
||||||
auto &impl) { return impl.SetProperty(prop_key, ToPropertyValue(*property_value), true); },
|
return impl.SetProperty(prop_key, ToPropertyValue(*property_value),
|
||||||
v->impl);
|
memgraph::flags::run_time::GetTextSearchEnabled());
|
||||||
|
},
|
||||||
|
v->impl);
|
||||||
if (result.HasError()) {
|
if (result.HasError()) {
|
||||||
switch (result.GetError()) {
|
switch (result.GetError()) {
|
||||||
case memgraph::storage::Error::DELETED_OBJECT:
|
case memgraph::storage::Error::DELETED_OBJECT:
|
||||||
@ -1897,7 +1900,7 @@ mgp_error mgp_vertex_set_properties(struct mgp_vertex *v, struct mgp_map *proper
|
|||||||
v->graph->impl));
|
v->graph->impl));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto result = v->getImpl().UpdateProperties(props, true);
|
const auto result = v->getImpl().UpdateProperties(props, memgraph::flags::run_time::GetTextSearchEnabled());
|
||||||
if (result.HasError()) {
|
if (result.HasError()) {
|
||||||
switch (result.GetError()) {
|
switch (result.GetError()) {
|
||||||
case memgraph::storage::Error::DELETED_OBJECT:
|
case memgraph::storage::Error::DELETED_OBJECT:
|
||||||
@ -1954,7 +1957,9 @@ mgp_error mgp_vertex_add_label(struct mgp_vertex *v, mgp_label label) {
|
|||||||
throw ImmutableObjectException{"Cannot add a label to an immutable vertex!"};
|
throw ImmutableObjectException{"Cannot add a label to an immutable vertex!"};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto result = std::visit([label_id](auto &impl) { return impl.AddLabel(label_id, true); }, v->impl);
|
const auto result = std::visit(
|
||||||
|
[label_id](auto &impl) { return impl.AddLabel(label_id, memgraph::flags::run_time::GetTextSearchEnabled()); },
|
||||||
|
v->impl);
|
||||||
|
|
||||||
if (result.HasError()) {
|
if (result.HasError()) {
|
||||||
switch (result.GetError()) {
|
switch (result.GetError()) {
|
||||||
@ -1996,7 +2001,11 @@ mgp_error mgp_vertex_remove_label(struct mgp_vertex *v, mgp_label label) {
|
|||||||
if (!MgpVertexIsMutable(*v)) {
|
if (!MgpVertexIsMutable(*v)) {
|
||||||
throw ImmutableObjectException{"Cannot remove a label from an immutable vertex!"};
|
throw ImmutableObjectException{"Cannot remove a label from an immutable vertex!"};
|
||||||
}
|
}
|
||||||
const auto result = std::visit([label_id](auto &impl) { return impl.RemoveLabel(label_id, true); }, v->impl);
|
const auto result = std::visit(
|
||||||
|
[label_id](auto &impl) {
|
||||||
|
return impl.RemoveLabel(label_id, memgraph::flags::run_time::GetTextSearchEnabled());
|
||||||
|
},
|
||||||
|
v->impl);
|
||||||
|
|
||||||
if (result.HasError()) {
|
if (result.HasError()) {
|
||||||
switch (result.GetError()) {
|
switch (result.GetError()) {
|
||||||
@ -3325,11 +3334,18 @@ mgp_error mgp_graph_delete_edge(struct mgp_graph *graph, mgp_edge *edge) {
|
|||||||
|
|
||||||
mgp_error mgp_graph_has_text_index(mgp_graph *graph, const char *index_name, int *result) {
|
mgp_error mgp_graph_has_text_index(mgp_graph *graph, const char *index_name, int *result) {
|
||||||
return WrapExceptions([graph, index_name, result]() {
|
return WrapExceptions([graph, index_name, result]() {
|
||||||
std::visit(memgraph::utils::Overloaded{
|
std::visit(memgraph::utils::Overloaded{[&](memgraph::query::DbAccessor *impl) {
|
||||||
[&](memgraph::query::DbAccessor *impl) { *result = impl->TextIndexExists(index_name); },
|
if (!memgraph::flags::run_time::GetTextSearchEnabled()) {
|
||||||
[&](memgraph::query::SubgraphDbAccessor *impl) {
|
// TODO antepusic throw exception
|
||||||
*result = impl->GetAccessor()->TextIndexExists(index_name);
|
}
|
||||||
}},
|
*result = impl->TextIndexExists(index_name);
|
||||||
|
},
|
||||||
|
[&](memgraph::query::SubgraphDbAccessor *impl) {
|
||||||
|
if (!memgraph::flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
*result = impl->GetAccessor()->TextIndexExists(index_name);
|
||||||
|
}},
|
||||||
graph->impl);
|
graph->impl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3376,9 +3392,15 @@ mgp_error mgp_graph_search_text_index(mgp_graph *graph, mgp_memory *memory, cons
|
|||||||
return WrapExceptions([graph, memory, index_name, search_query, result]() {
|
return WrapExceptions([graph, memory, index_name, search_query, result]() {
|
||||||
std::visit(memgraph::utils::Overloaded{
|
std::visit(memgraph::utils::Overloaded{
|
||||||
[&](memgraph::query::DbAccessor *impl) {
|
[&](memgraph::query::DbAccessor *impl) {
|
||||||
|
if (!memgraph::flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
WrapIntoVertexList(impl->SearchTextIndex(index_name, search_query), graph, memory, result);
|
WrapIntoVertexList(impl->SearchTextIndex(index_name, search_query), graph, memory, result);
|
||||||
},
|
},
|
||||||
[&](memgraph::query::SubgraphDbAccessor *impl) {
|
[&](memgraph::query::SubgraphDbAccessor *impl) {
|
||||||
|
if (!memgraph::flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
WrapIntoVertexList(impl->GetAccessor()->SearchTextIndex(index_name, search_query), graph, memory,
|
WrapIntoVertexList(impl->GetAccessor()->SearchTextIndex(index_name, search_query), graph, memory,
|
||||||
result);
|
result);
|
||||||
}},
|
}},
|
||||||
|
@ -57,14 +57,14 @@ struct Indices {
|
|||||||
/// This function should be called whenever a label is added to a vertex.
|
/// This function should be called whenever a label is added to a vertex.
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
void UpdateOnAddLabel(LabelId label, Vertex *vertex, const Transaction &tx, Storage *storage,
|
void UpdateOnAddLabel(LabelId label, Vertex *vertex, const Transaction &tx, Storage *storage,
|
||||||
bool update_text_index) const;
|
bool update_text_index = false) const;
|
||||||
|
|
||||||
void UpdateOnRemoveLabel(LabelId label, Vertex *vertex, const Transaction &tx, bool update_text_index) const;
|
void UpdateOnRemoveLabel(LabelId label, Vertex *vertex, const Transaction &tx, bool update_text_index = false) const;
|
||||||
|
|
||||||
/// This function should be called whenever a property is modified on a vertex.
|
/// This function should be called whenever a property is modified on a vertex.
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
void UpdateOnSetProperty(PropertyId property, const PropertyValue &value, Vertex *vertex, const Transaction &tx,
|
void UpdateOnSetProperty(PropertyId property, const PropertyValue &value, Vertex *vertex, const Transaction &tx,
|
||||||
Storage *storage, bool update_text_index) const;
|
Storage *storage, bool update_text_index = false) const;
|
||||||
|
|
||||||
std::unique_ptr<LabelIndex> label_index_;
|
std::unique_ptr<LabelIndex> label_index_;
|
||||||
std::unique_ptr<LabelPropertyIndex> label_property_index_;
|
std::unique_ptr<LabelPropertyIndex> label_property_index_;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
// licenses/APL.txt.
|
// licenses/APL.txt.
|
||||||
|
|
||||||
#include "storage/v2/indices/text_index.hpp"
|
#include "storage/v2/indices/text_index.hpp"
|
||||||
|
#include "flags/run_time_configurable.hpp"
|
||||||
#include "query/db_accessor.hpp"
|
#include "query/db_accessor.hpp"
|
||||||
#include "storage/v2/view.hpp"
|
#include "storage/v2/view.hpp"
|
||||||
#include "text_search.hpp"
|
#include "text_search.hpp"
|
||||||
@ -18,6 +19,10 @@ namespace memgraph::storage {
|
|||||||
|
|
||||||
void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std::uint64_t transaction_start_timestamp,
|
void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std::uint64_t transaction_start_timestamp,
|
||||||
const std::vector<mgcxx::text_search::Context *> &applicable_text_indices, bool skip_commit) {
|
const std::vector<mgcxx::text_search::Context *> &applicable_text_indices, bool skip_commit) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Text indexes are presently all-property indices. If we allow text indexes restricted to specific properties,
|
// NOTE: Text indexes are presently all-property indices. If we allow text indexes restricted to specific properties,
|
||||||
// an indexable document should be created for each applicable index.
|
// an indexable document should be created for each applicable index.
|
||||||
nlohmann::json document = {};
|
nlohmann::json document = {};
|
||||||
@ -58,7 +63,7 @@ void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std
|
|||||||
*index_context,
|
*index_context,
|
||||||
mgcxx::text_search::DocumentInput{
|
mgcxx::text_search::DocumentInput{
|
||||||
.data = document.dump(-1, ' ', false, nlohmann::json::error_handler_t::replace)},
|
.data = document.dump(-1, ' ', false, nlohmann::json::error_handler_t::replace)},
|
||||||
false);
|
skip_commit);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
throw query::QueryException(fmt::format("Tantivy error: {}", e.what()));
|
throw query::QueryException(fmt::format("Tantivy error: {}", e.what()));
|
||||||
}
|
}
|
||||||
@ -67,6 +72,10 @@ void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std
|
|||||||
|
|
||||||
void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std::uint64_t transaction_start_timestamp,
|
void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std::uint64_t transaction_start_timestamp,
|
||||||
bool skip_commit) {
|
bool skip_commit) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
auto applicable_text_indices = GetApplicableTextIndices(vertex_after_update);
|
auto applicable_text_indices = GetApplicableTextIndices(vertex_after_update);
|
||||||
if (applicable_text_indices.empty()) return;
|
if (applicable_text_indices.empty()) return;
|
||||||
AddNode(vertex_after_update, storage, transaction_start_timestamp, applicable_text_indices, skip_commit);
|
AddNode(vertex_after_update, storage, transaction_start_timestamp, applicable_text_indices, skip_commit);
|
||||||
@ -74,6 +83,10 @@ void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std
|
|||||||
|
|
||||||
void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage,
|
void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage,
|
||||||
const std::uint64_t transaction_start_timestamp) {
|
const std::uint64_t transaction_start_timestamp) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
auto applicable_text_indices = GetApplicableTextIndices(vertex_after_update);
|
auto applicable_text_indices = GetApplicableTextIndices(vertex_after_update);
|
||||||
if (applicable_text_indices.empty()) return;
|
if (applicable_text_indices.empty()) return;
|
||||||
RemoveNode(vertex_after_update, applicable_text_indices);
|
RemoveNode(vertex_after_update, applicable_text_indices);
|
||||||
@ -83,6 +96,10 @@ void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage,
|
|||||||
void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage,
|
void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage,
|
||||||
const std::uint64_t transaction_start_timestamp,
|
const std::uint64_t transaction_start_timestamp,
|
||||||
const std::vector<LabelId> &removed_labels) {
|
const std::vector<LabelId> &removed_labels) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
auto indexes_to_remove_node_from = GetApplicableTextIndices(removed_labels);
|
auto indexes_to_remove_node_from = GetApplicableTextIndices(removed_labels);
|
||||||
RemoveNode(vertex_after_update, indexes_to_remove_node_from);
|
RemoveNode(vertex_after_update, indexes_to_remove_node_from);
|
||||||
|
|
||||||
@ -94,12 +111,16 @@ void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage,
|
|||||||
|
|
||||||
void TextIndex::RemoveNode(Vertex *vertex_after_update,
|
void TextIndex::RemoveNode(Vertex *vertex_after_update,
|
||||||
const std::vector<mgcxx::text_search::Context *> &applicable_text_indices) {
|
const std::vector<mgcxx::text_search::Context *> &applicable_text_indices) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
auto search_node_to_be_deleted =
|
auto search_node_to_be_deleted =
|
||||||
mgcxx::text_search::SearchInput{.search_query = fmt::format("metadata.gid:{}", vertex_after_update->gid.AsInt())};
|
mgcxx::text_search::SearchInput{.search_query = fmt::format("metadata.gid:{}", vertex_after_update->gid.AsInt())};
|
||||||
|
|
||||||
for (auto *index_context : applicable_text_indices) {
|
for (auto *index_context : applicable_text_indices) {
|
||||||
try {
|
try {
|
||||||
mgcxx::text_search::delete_document(*index_context, search_node_to_be_deleted, false);
|
mgcxx::text_search::delete_document(*index_context, search_node_to_be_deleted, KDoSkipCommit);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
throw query::QueryException(fmt::format("Tantivy error: {}", e.what()));
|
throw query::QueryException(fmt::format("Tantivy error: {}", e.what()));
|
||||||
}
|
}
|
||||||
@ -107,6 +128,10 @@ void TextIndex::RemoveNode(Vertex *vertex_after_update,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextIndex::RemoveNode(Vertex *vertex_after_update) {
|
void TextIndex::RemoveNode(Vertex *vertex_after_update) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
auto applicable_text_indices = GetApplicableTextIndices(vertex_after_update);
|
auto applicable_text_indices = GetApplicableTextIndices(vertex_after_update);
|
||||||
if (applicable_text_indices.empty()) return;
|
if (applicable_text_indices.empty()) return;
|
||||||
RemoveNode(vertex_after_update, applicable_text_indices);
|
RemoveNode(vertex_after_update, applicable_text_indices);
|
||||||
@ -114,6 +139,10 @@ void TextIndex::RemoveNode(Vertex *vertex_after_update) {
|
|||||||
|
|
||||||
void TextIndex::UpdateOnAddLabel(LabelId added_label, Vertex *vertex_after_update, Storage *storage,
|
void TextIndex::UpdateOnAddLabel(LabelId added_label, Vertex *vertex_after_update, Storage *storage,
|
||||||
const std::uint64_t transaction_start_timestamp) {
|
const std::uint64_t transaction_start_timestamp) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
if (!label_to_index_.contains(added_label)) {
|
if (!label_to_index_.contains(added_label)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -123,6 +152,10 @@ void TextIndex::UpdateOnAddLabel(LabelId added_label, Vertex *vertex_after_updat
|
|||||||
|
|
||||||
void TextIndex::UpdateOnRemoveLabel(LabelId removed_label, Vertex *vertex_after_update,
|
void TextIndex::UpdateOnRemoveLabel(LabelId removed_label, Vertex *vertex_after_update,
|
||||||
const std::uint64_t transaction_start_timestamp) {
|
const std::uint64_t transaction_start_timestamp) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
if (!label_to_index_.contains(removed_label)) {
|
if (!label_to_index_.contains(removed_label)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -131,10 +164,18 @@ void TextIndex::UpdateOnRemoveLabel(LabelId removed_label, Vertex *vertex_after_
|
|||||||
|
|
||||||
void TextIndex::UpdateOnSetProperty(Vertex *vertex_after_update, Storage *storage,
|
void TextIndex::UpdateOnSetProperty(Vertex *vertex_after_update, Storage *storage,
|
||||||
std::uint64_t transaction_start_timestamp) {
|
std::uint64_t transaction_start_timestamp) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
UpdateNode(vertex_after_update, storage, transaction_start_timestamp);
|
UpdateNode(vertex_after_update, storage, transaction_start_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<mgcxx::text_search::Context *> TextIndex::GetApplicableTextIndices(const std::vector<LabelId> &labels) {
|
std::vector<mgcxx::text_search::Context *> TextIndex::GetApplicableTextIndices(const std::vector<LabelId> &labels) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<mgcxx::text_search::Context *> applicable_text_indices;
|
std::vector<mgcxx::text_search::Context *> applicable_text_indices;
|
||||||
for (const auto &label : labels) {
|
for (const auto &label : labels) {
|
||||||
if (label_to_index_.contains(label)) {
|
if (label_to_index_.contains(label)) {
|
||||||
@ -145,6 +186,10 @@ std::vector<mgcxx::text_search::Context *> TextIndex::GetApplicableTextIndices(c
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<mgcxx::text_search::Context *> TextIndex::GetApplicableTextIndices(Vertex *vertex) {
|
std::vector<mgcxx::text_search::Context *> TextIndex::GetApplicableTextIndices(Vertex *vertex) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<mgcxx::text_search::Context *> applicable_text_indices;
|
std::vector<mgcxx::text_search::Context *> applicable_text_indices;
|
||||||
for (const auto &label : vertex->labels) {
|
for (const auto &label : vertex->labels) {
|
||||||
if (label_to_index_.contains(label)) {
|
if (label_to_index_.contains(label)) {
|
||||||
@ -155,6 +200,10 @@ std::vector<mgcxx::text_search::Context *> TextIndex::GetApplicableTextIndices(V
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TextIndex::CreateIndex(std::string index_name, LabelId label, memgraph::query::DbAccessor *db) {
|
bool TextIndex::CreateIndex(std::string index_name, LabelId label, memgraph::query::DbAccessor *db) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
nlohmann::json mappings = {};
|
nlohmann::json mappings = {};
|
||||||
mappings["properties"] = {};
|
mappings["properties"] = {};
|
||||||
mappings["properties"]["metadata"] = {{"type", "json"}, {"fast", true}, {"stored", true}, {"text", true}};
|
mappings["properties"]["metadata"] = {{"type", "json"}, {"fast", true}, {"stored", true}, {"text", true}};
|
||||||
@ -225,21 +274,25 @@ bool TextIndex::CreateIndex(std::string index_name, LabelId label, memgraph::que
|
|||||||
index_context,
|
index_context,
|
||||||
mgcxx::text_search::DocumentInput{
|
mgcxx::text_search::DocumentInput{
|
||||||
.data = document.dump(-1, ' ', false, nlohmann::json::error_handler_t::replace)},
|
.data = document.dump(-1, ' ', false, nlohmann::json::error_handler_t::replace)},
|
||||||
true);
|
KDoSkipCommit);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
throw query::QueryException(fmt::format("Tantivy error: {}", e.what()));
|
throw query::QueryException(fmt::format("Tantivy error: {}", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
mgcxx::text_search::commit(index_context);
|
// mgcxx::text_search::commit(index_context);
|
||||||
} catch (const std::exception &e) {
|
// } catch (const std::exception &e) {
|
||||||
throw query::QueryException(fmt::format("Tantivy error: {}", e.what()));
|
// throw query::QueryException(fmt::format("Tantivy error: {}", e.what()));
|
||||||
}
|
// }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextIndex::DropIndex(std::string index_name) {
|
bool TextIndex::DropIndex(std::string index_name) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mgcxx::text_search::drop_index(index_name);
|
mgcxx::text_search::drop_index(index_name);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
@ -253,6 +306,10 @@ bool TextIndex::DropIndex(std::string index_name) {
|
|||||||
bool TextIndex::IndexExists(std::string index_name) const { return index_.contains(index_name); }
|
bool TextIndex::IndexExists(std::string index_name) const { return index_.contains(index_name); }
|
||||||
|
|
||||||
std::vector<Gid> TextIndex::Search(std::string index_name, std::string search_query) {
|
std::vector<Gid> TextIndex::Search(std::string index_name, std::string search_query) {
|
||||||
|
if (!flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic throw exception
|
||||||
|
}
|
||||||
|
|
||||||
auto input = mgcxx::text_search::SearchInput{.search_query = search_query, .return_fields = {"data", "metadata"}};
|
auto input = mgcxx::text_search::SearchInput{.search_query = search_query, .return_fields = {"data", "metadata"}};
|
||||||
// Basic check for search fields in the query (Tantivy syntax delimits them with a `:` to the right)
|
// Basic check for search fields in the query (Tantivy syntax delimits them with a `:` to the right)
|
||||||
if (search_query.find(":") == std::string::npos) {
|
if (search_query.find(":") == std::string::npos) {
|
||||||
|
@ -23,6 +23,8 @@ class DbAccessor;
|
|||||||
namespace memgraph::storage {
|
namespace memgraph::storage {
|
||||||
class Storage;
|
class Storage;
|
||||||
|
|
||||||
|
constexpr bool KDoSkipCommit = true;
|
||||||
|
|
||||||
struct TextIndexData {
|
struct TextIndexData {
|
||||||
mgcxx::text_search::Context context_;
|
mgcxx::text_search::Context context_;
|
||||||
LabelId scope_;
|
LabelId scope_;
|
||||||
@ -31,10 +33,12 @@ struct TextIndexData {
|
|||||||
class TextIndex {
|
class TextIndex {
|
||||||
private:
|
private:
|
||||||
void AddNode(Vertex *vertex, Storage *storage, const std::uint64_t transaction_start_timestamp,
|
void AddNode(Vertex *vertex, Storage *storage, const std::uint64_t transaction_start_timestamp,
|
||||||
const std::vector<mgcxx::text_search::Context *> &applicable_text_indices, bool skip_commit = false);
|
const std::vector<mgcxx::text_search::Context *> &applicable_text_indices, bool skip_commit = true);
|
||||||
|
|
||||||
std::vector<mgcxx::text_search::Context *> GetApplicableTextIndices(const std::vector<LabelId> &labels);
|
std::vector<mgcxx::text_search::Context *> GetApplicableTextIndices(const std::vector<LabelId> &labels);
|
||||||
|
|
||||||
|
std::vector<mgcxx::text_search::Context *> GetApplicableTextIndices(Vertex *vertex);
|
||||||
|
|
||||||
void RemoveNode(Vertex *vertex, const std::vector<mgcxx::text_search::Context *> &applicable_text_indices);
|
void RemoveNode(Vertex *vertex, const std::vector<mgcxx::text_search::Context *> &applicable_text_indices);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -51,7 +55,7 @@ class TextIndex {
|
|||||||
std::map<LabelId, std::string> label_to_index_;
|
std::map<LabelId, std::string> label_to_index_;
|
||||||
|
|
||||||
void AddNode(Vertex *vertex, Storage *storage, const std::uint64_t transaction_start_timestamp,
|
void AddNode(Vertex *vertex, Storage *storage, const std::uint64_t transaction_start_timestamp,
|
||||||
bool skip_commit = false);
|
bool skip_commit = true);
|
||||||
|
|
||||||
void UpdateNode(Vertex *vertex, Storage *storage, const std::uint64_t transaction_start_timestamp);
|
void UpdateNode(Vertex *vertex, Storage *storage, const std::uint64_t transaction_start_timestamp);
|
||||||
|
|
||||||
@ -69,8 +73,6 @@ class TextIndex {
|
|||||||
void UpdateOnSetProperty(Vertex *vertex_after_update, Storage *storage,
|
void UpdateOnSetProperty(Vertex *vertex_after_update, Storage *storage,
|
||||||
const std::uint64_t transaction_start_timestamp);
|
const std::uint64_t transaction_start_timestamp);
|
||||||
|
|
||||||
std::vector<mgcxx::text_search::Context *> GetApplicableTextIndices(Vertex *vertex);
|
|
||||||
|
|
||||||
bool CreateIndex(std::string index_name, LabelId label, memgraph::query::DbAccessor *db);
|
bool CreateIndex(std::string index_name, LabelId label, memgraph::query::DbAccessor *db);
|
||||||
|
|
||||||
bool DropIndex(std::string index_name);
|
bool DropIndex(std::string index_name);
|
||||||
|
@ -149,6 +149,7 @@ Result<std::optional<VertexAccessor>> Storage::Accessor::DeleteVertex(VertexAcce
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags::run_time::GetTextSearchEnabled()) {
|
if (flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic cleanup call
|
||||||
vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_);
|
vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,6 +191,7 @@ Result<std::optional<std::pair<VertexAccessor, std::vector<EdgeAccessor>>>> Stor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags::run_time::GetTextSearchEnabled()) {
|
if (flags::run_time::GetTextSearchEnabled()) {
|
||||||
|
// TODO antepusic cleanup call
|
||||||
vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_);
|
vertex->storage_->indices_.text_index_->RemoveNode(vertex->vertex_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,6 +285,7 @@ Storage::Accessor::DetachDelete(std::vector<VertexAccessor *> nodes, std::vector
|
|||||||
|
|
||||||
if (flags::run_time::GetTextSearchEnabled()) {
|
if (flags::run_time::GetTextSearchEnabled()) {
|
||||||
for (auto *node : nodes_to_delete) {
|
for (auto *node : nodes_to_delete) {
|
||||||
|
// TODO antepusic cleanup call
|
||||||
storage_->indices_.text_index_->RemoveNode(node);
|
storage_->indices_.text_index_->RemoveNode(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,10 +256,6 @@ class Storage {
|
|||||||
|
|
||||||
std::vector<EdgeTypeId> ListAllPossiblyPresentEdgeTypes() const;
|
std::vector<EdgeTypeId> ListAllPossiblyPresentEdgeTypes() const;
|
||||||
|
|
||||||
std::vector<Gid> TextSearch(std::string index_name, std::string &search_query) const {
|
|
||||||
return storage_->indices_.text_index_->Search(index_name, search_query);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual utils::BasicResult<StorageIndexDefinitionError, void> CreateIndex(LabelId label) = 0;
|
virtual utils::BasicResult<StorageIndexDefinitionError, void> CreateIndex(LabelId label) = 0;
|
||||||
|
|
||||||
virtual utils::BasicResult<StorageIndexDefinitionError, void> CreateIndex(LabelId label, PropertyId property) = 0;
|
virtual utils::BasicResult<StorageIndexDefinitionError, void> CreateIndex(LabelId label, PropertyId property) = 0;
|
||||||
@ -270,11 +266,13 @@ class Storage {
|
|||||||
|
|
||||||
virtual utils::BasicResult<StorageIndexDefinitionError, void> CreateTextIndex(std::string index_name, LabelId label,
|
virtual utils::BasicResult<StorageIndexDefinitionError, void> CreateTextIndex(std::string index_name, LabelId label,
|
||||||
query::DbAccessor *db) {
|
query::DbAccessor *db) {
|
||||||
|
// TODO antepusic cleanup call
|
||||||
storage_->indices_.text_index_->CreateIndex(index_name, label, db);
|
storage_->indices_.text_index_->CreateIndex(index_name, label, db);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual utils::BasicResult<StorageIndexDefinitionError, void> DropTextIndex(std::string index_name) {
|
virtual utils::BasicResult<StorageIndexDefinitionError, void> DropTextIndex(std::string index_name) {
|
||||||
|
// TODO antepusic cleanup call
|
||||||
storage_->indices_.text_index_->DropIndex(index_name);
|
storage_->indices_.text_index_->DropIndex(index_name);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -47,12 +47,12 @@ class VertexAccessor final {
|
|||||||
/// Add a label and return `true` if insertion took place.
|
/// Add a label and return `true` if insertion took place.
|
||||||
/// `false` is returned if the label already existed.
|
/// `false` is returned if the label already existed.
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
Result<bool> AddLabel(LabelId label, bool update_text_index);
|
Result<bool> AddLabel(LabelId label, bool update_text_index = false);
|
||||||
|
|
||||||
/// Remove a label and return `true` if deletion took place.
|
/// Remove a label and return `true` if deletion took place.
|
||||||
/// `false` is returned if the vertex did not have a label already.
|
/// `false` is returned if the vertex did not have a label already.
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
Result<bool> RemoveLabel(LabelId label, bool update_text_index);
|
Result<bool> RemoveLabel(LabelId label, bool update_text_index = false);
|
||||||
|
|
||||||
Result<bool> HasLabel(LabelId label, View view) const;
|
Result<bool> HasLabel(LabelId label, View view) const;
|
||||||
|
|
||||||
@ -63,20 +63,20 @@ class VertexAccessor final {
|
|||||||
|
|
||||||
/// Set a property value and return the old value.
|
/// Set a property value and return the old value.
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
Result<PropertyValue> SetProperty(PropertyId property, const PropertyValue &value, bool update_text_index);
|
Result<PropertyValue> SetProperty(PropertyId property, const PropertyValue &value, bool update_text_index = false);
|
||||||
|
|
||||||
/// Set property values only if property store is empty. Returns `true` if successully set all values,
|
/// Set property values only if property store is empty. Returns `true` if successully set all values,
|
||||||
/// `false` otherwise.
|
/// `false` otherwise.
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
Result<bool> InitProperties(const std::map<storage::PropertyId, storage::PropertyValue> &properties,
|
Result<bool> InitProperties(const std::map<storage::PropertyId, storage::PropertyValue> &properties,
|
||||||
bool update_text_index);
|
bool update_text_index = false);
|
||||||
|
|
||||||
Result<std::vector<std::tuple<PropertyId, PropertyValue, PropertyValue>>> UpdateProperties(
|
Result<std::vector<std::tuple<PropertyId, PropertyValue, PropertyValue>>> UpdateProperties(
|
||||||
std::map<storage::PropertyId, storage::PropertyValue> &properties, bool update_text_index) const;
|
std::map<storage::PropertyId, storage::PropertyValue> &properties, bool update_text_index = false) const;
|
||||||
|
|
||||||
/// Remove all properties and return the values of the removed properties.
|
/// Remove all properties and return the values of the removed properties.
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
Result<std::map<PropertyId, PropertyValue>> ClearProperties(bool update_text_index);
|
Result<std::map<PropertyId, PropertyValue>> ClearProperties(bool update_text_index = false);
|
||||||
|
|
||||||
/// @throw std::bad_alloc
|
/// @throw std::bad_alloc
|
||||||
Result<PropertyValue> GetProperty(PropertyId property, View view) const;
|
Result<PropertyValue> GetProperty(PropertyId property, View view) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user