|
|
@@ -56,19 +56,19 @@ int main() {
|
|
|
Document doc1;
|
|
|
doc1.id = "doc1";
|
|
|
doc1.collection = "test_vectors";
|
|
|
- doc1.data = {{"content", "hello"}, {"_vector", {1.0f, 0.0f, 0.0f}}};
|
|
|
+ doc1.set_data({{"content", "hello"}, {"_vector", {1.0f, 0.0f, 0.0f}}});
|
|
|
store.insert("test_vectors", doc1);
|
|
|
|
|
|
Document doc2;
|
|
|
doc2.id = "doc2";
|
|
|
doc2.collection = "test_vectors";
|
|
|
- doc2.data = {{"content", "world"}, {"_vector", {0.0f, 1.0f, 0.0f}}};
|
|
|
+ doc2.set_data({{"content", "world"}, {"_vector", {0.0f, 1.0f, 0.0f}}});
|
|
|
store.insert("test_vectors", doc2);
|
|
|
|
|
|
Document doc3;
|
|
|
doc3.id = "doc3";
|
|
|
doc3.collection = "test_vectors";
|
|
|
- doc3.data = {{"content", "similar"}, {"_vector", {0.9f, 0.1f, 0.0f}}};
|
|
|
+ doc3.set_data({{"content", "similar"}, {"_vector", {0.9f, 0.1f, 0.0f}}});
|
|
|
store.insert("test_vectors", doc3);
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
@@ -88,8 +88,8 @@ int main() {
|
|
|
// ---------------------------------------------------------------
|
|
|
auto stored = store.get("test_vectors", "doc1");
|
|
|
check(stored.has_value(), "doc1 should exist after insert");
|
|
|
- check(!stored->data.contains("_vector"), "_vector should be stripped from stored doc");
|
|
|
- check(stored->data["content"] == "hello", "doc1 content should be 'hello'");
|
|
|
+ check(!stored->field("_vector").has_value(),"_vector should be stripped from stored doc");
|
|
|
+ check(stored->data()["content"] == "hello", "doc1 content should be 'hello'");
|
|
|
std::cout << "PASS: _vector stripped from document data\n";
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
@@ -99,7 +99,7 @@ int main() {
|
|
|
Document bad;
|
|
|
bad.id = "bad";
|
|
|
bad.collection = "test_vectors";
|
|
|
- bad.data = {{"_vector", {1.0f, 2.0f}}}; // wrong dim (2 instead of 3)
|
|
|
+ bad.set_data({{"_vector", {1.0f, 2.0f}}}); // wrong dim (2 instead of 3)
|
|
|
store.insert("test_vectors", bad);
|
|
|
check(false, "dimension mismatch should have thrown");
|
|
|
} catch (const std::invalid_argument& e) {
|
|
|
@@ -137,7 +137,7 @@ int main() {
|
|
|
Document doc2_updated;
|
|
|
doc2_updated.id = "doc2";
|
|
|
doc2_updated.collection = "test_vectors";
|
|
|
- doc2_updated.data = {{"content", "updated"}, {"_vector", {1.0f, 0.0f, 0.0f}}};
|
|
|
+ doc2_updated.set_data({{"content", "updated"}, {"_vector", {1.0f, 0.0f, 0.0f}}});
|
|
|
store.update("test_vectors", "doc2", doc2_updated);
|
|
|
|
|
|
auto after_update = store.similaritySearch("test_vectors", {1.0f, 0.0f, 0.0f}, 1);
|