Skip to content

Commit

Permalink
[NOID] various changes for 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed Nov 27, 2024
1 parent 9c0d67a commit d15f7e5
Show file tree
Hide file tree
Showing 28 changed files with 241 additions and 473 deletions.
68 changes: 0 additions & 68 deletions extended/src/main/java/apoc/agg/AggregationExtended.java

This file was deleted.

41 changes: 0 additions & 41 deletions extended/src/main/java/apoc/systemdb/metadata/ExportFunction.java

This file was deleted.

40 changes: 0 additions & 40 deletions extended/src/main/java/apoc/systemdb/metadata/ExportProcedure.java

This file was deleted.

15 changes: 0 additions & 15 deletions extended/src/main/java/apoc/util/UtilsExtended.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.driver.*;
import org.neo4j.driver.Record;
import org.neo4j.internal.helpers.collection.Iterators;

@Ignore
Expand Down
31 changes: 13 additions & 18 deletions full-it/src/test/java/apoc/full/it/vectordb/ChromaDbTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package apoc.full.it.vectordb;

import apoc.util.TestUtil;
import apoc.util.Util;
import apoc.vectordb.ChromaDb;
import apoc.vectordb.VectorDb;
import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -71,13 +72,11 @@ public static void setUp() throws Exception {
COLL_ID.set((String) value.get("id"));
});

testCall(db, """
CALL apoc.vectordb.chroma.upsert($host, $collection,
[
{id: '1', vector: [0.05, 0.61, 0.76, 0.74], metadata: {city: "Berlin", foo: "one"}, text: 'ajeje'},
{id: '2', vector: [0.19, 0.81, 0.75, 0.11], metadata: {city: "London", foo: "two"}, text: 'brazorf'}
])
""",
testCall(db, "CALL apoc.vectordb.chroma.upsert($host, $collection,\n" +
" [\n" +
" {id: '1', vector: [0.05, 0.61, 0.76, 0.74], metadata: {city: \"Berlin\", foo: \"one\"}, text: 'ajeje'},\n" +
" {id: '2', vector: [0.19, 0.81, 0.75, 0.11], metadata: {city: \"London\", foo: \"two\"}, text: 'brazorf'}\n" +
" ])",
map("host", HOST, "collection", COLL_ID.get()),
r -> {
assertNull(r.get("value"));
Expand Down Expand Up @@ -128,12 +127,10 @@ public void getVectorsWithoutVectorResult() {

@Test
public void deleteVector() {
testCall(db, """
CALL apoc.vectordb.chroma.upsert($host, $collection,
[
{id: 3, embedding: [0.19, 0.81, 0.75, 0.11], metadata: {foo: "baz"}}
])
""",
testCall(db, "CALL apoc.vectordb.chroma.upsert($host, $collection,\n" +
"[\n" +
" {id: 3, embedding: [0.19, 0.81, 0.75, 0.11], metadata: {foo: \"baz\"}}\n" +
"])",
map("host", HOST, "collection", COLL_ID.get()),
r -> {
assertNull(r.get("value"));
Expand Down Expand Up @@ -206,8 +203,7 @@ public void queryVectorsWithYield() {

@Test
public void queryVectorsWithFilter() {
testResult(db, """
CALL apoc.vectordb.chroma.query($host, $collection, [0.2, 0.1, 0.9, 0.7], {city: 'London'}, 5, $conf) YIELD metadata, id""",
testResult(db, "CALL apoc.vectordb.chroma.query($host, $collection, [0.2, 0.1, 0.9, 0.7], {city: 'London'}, 5, $conf) YIELD metadata, id",
map("host", HOST, "collection", COLL_ID.get(), "conf", map(ALL_RESULTS_KEY, true)),
r -> {
assertLondonResult(r.next(), FALSE);
Expand All @@ -216,8 +212,7 @@ public void queryVectorsWithFilter() {

@Test
public void queryVectorsWithLimit() {
testResult(db, """
CALL apoc.vectordb.chroma.query($host, $collection, [0.2, 0.1, 0.9, 0.7], {}, 1, $conf) YIELD metadata, id""",
testResult(db, "CALL apoc.vectordb.chroma.query($host, $collection, [0.2, 0.1, 0.9, 0.7], {}, 1, $conf) YIELD metadata, id",
map("host", HOST, "collection", COLL_ID.get(), "conf", map(ALL_RESULTS_KEY, true)),
r -> {
assertBerlinResult(r.next(), FALSE);
Expand Down
45 changes: 21 additions & 24 deletions full-it/src/test/java/apoc/full/it/vectordb/QdrantTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import apoc.util.TestUtil;
import apoc.util.Util;
import apoc.vectordb.Qdrant;
import apoc.vectordb.VectorDb;
import apoc.vectordb.VectorDbTestUtil;
import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -81,14 +84,12 @@ public static void setUp() throws Exception {
assertEquals("ok", value.get("status"));
});

testCall(db, """
CALL apoc.vectordb.qdrant.upsert($host, 'test_collection',
[
{id: 1, vector: [0.05, 0.61, 0.76, 0.74], metadata: {city: "Berlin", foo: "one"}},
{id: 2, vector: [0.19, 0.81, 0.75, 0.11], metadata: {city: "London", foo: "two"}}
],
$conf)
""",
testCall(db, "CALL apoc.vectordb.qdrant.upsert($host, 'test_collection',\n" +
"[\n" +
" {id: 1, vector: [0.05, 0.61, 0.76, 0.74], metadata: {city: \"Berlin\", foo: \"one\"}},\n" +
" {id: 2, vector: [0.19, 0.81, 0.75, 0.11], metadata: {city: \"London\", foo: \"two\"}}\n" +
"],\n" +
"$conf)",
map("host", HOST, "conf", ADMIN_HEADER_CONF),
r -> {
Map value = (Map) r.get("value");
Expand Down Expand Up @@ -155,14 +156,12 @@ public void getVectorsWithoutVectorResult() {

@Test
public void deleteVector() {
testCall(db, """
CALL apoc.vectordb.qdrant.upsert($host, 'test_collection',
[
{id: 3, vector: [0.19, 0.81, 0.75, 0.11], metadata: {foo: "baz"}},
{id: 4, vector: [0.19, 0.81, 0.75, 0.11], metadata: {foo: "baz"}}
],
$conf)
""",
testCall(db, "CALL apoc.vectordb.qdrant.upsert($host, 'test_collection',\n" +
"[\n" +
" {id: 3, vector: [0.19, 0.81, 0.75, 0.11], metadata: {foo: \"baz\"}},\n" +
" {id: 4, vector: [0.19, 0.81, 0.75, 0.11], metadata: {foo: \"baz\"}}\n" +
"],\n" +
"$conf)",
map("host", HOST, "conf", ADMIN_HEADER_CONF),
r -> {
Map value = (Map) r.get("value");
Expand Down Expand Up @@ -227,12 +226,11 @@ public void queryVectorsWithYield() {

@Test
public void queryVectorsWithFilter() {
testResult(db, """
CALL apoc.vectordb.qdrant.query($host, 'test_collection', [0.2, 0.1, 0.9, 0.7],
{ must:
[ { key: "city", match: { value: "London" } } ]
},
5, $conf) YIELD metadata, id""",
testResult(db, "CALL apoc.vectordb.qdrant.query($host, 'test_collection', [0.2, 0.1, 0.9, 0.7],\n" +
"{ must:\n" +
" [ { key: \"city\", match: { value: \"London\" } } ]\n" +
"},\n" +
"5, $conf) YIELD metadata, id",
map("host", HOST,
"conf", map(ALL_RESULTS_KEY, true, HEADERS_KEY, ADMIN_AUTHORIZATION)
),
Expand All @@ -243,8 +241,7 @@ public void queryVectorsWithFilter() {

@Test
public void queryVectorsWithLimit() {
testResult(db, """
CALL apoc.vectordb.qdrant.query($host, 'test_collection', [0.2, 0.1, 0.9, 0.7], {}, 1, $conf) YIELD metadata, id""",
testResult(db, "CALL apoc.vectordb.qdrant.query($host, 'test_collection', [0.2, 0.1, 0.9, 0.7], {}, 1, $conf) YIELD metadata, id",
map("host", HOST,
"conf", map(ALL_RESULTS_KEY, true, HEADERS_KEY, ADMIN_AUTHORIZATION)
),
Expand Down
29 changes: 13 additions & 16 deletions full-it/src/test/java/apoc/full/it/vectordb/WeaviateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import apoc.util.MapUtil;
import apoc.util.TestUtil;
import apoc.vectordb.VectorDb;
import apoc.vectordb.VectorDbTestUtil;
import apoc.vectordb.Weaviate;
import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -90,16 +93,12 @@ public static void setUp() throws Exception {
assertEquals("TestCollection", value.get("class"));
});

testResult(db, """
CALL apoc.vectordb.weaviate.upsert($host, 'TestCollection',
[
{id: $id1, vector: [0.05, 0.61, 0.76, 0.74], metadata: {city: "Berlin", foo: "one"}},
{id: $id2, vector: [0.19, 0.81, 0.75, 0.11], metadata: {city: "London", foo: "two"}},
{id: '7ef2b3a7-1e56-4ddd-b8c3-2ca8901ce308', vector: [0.19, 0.81, 0.75, 0.11], metadata: {foo: "baz"}},
{id: '7ef2b3a7-1e56-4ddd-b8c3-2ca8901ce309', vector: [0.19, 0.81, 0.75, 0.11], metadata: {foo: "baz"}}
],
$conf)
""",
testResult(db, "CALL apoc.vectordb.weaviate.upsert($host, 'TestCollection', [\n" +
" {id: $id1, vector: [0.05, 0.61, 0.76, 0.74], metadata: {city: \"Berlin\", foo: \"one\"}},\n" +
" {id: $id2, vector: [0.19, 0.81, 0.75, 0.11], metadata: {city: \"London\", foo: \"two\"}},\n" +
" {id: '7ef2b3a7-1e56-4ddd-b8c3-2ca8901ce308', vector: [0.19, 0.81, 0.75, 0.11], metadata: {foo: \"baz\"}},\n" +
" {id: '7ef2b3a7-1e56-4ddd-b8c3-2ca8901ce309', vector: [0.19, 0.81, 0.75, 0.11], metadata: {foo: \"baz\"}}\n" +
"], $conf)",
MapUtil.map("host", HOST, "id1", ID_1, "id2", ID_2, "conf", ADMIN_HEADER_CONF),
r -> {
ResourceIterator<Map> values = r.columnAs("value");
Expand Down Expand Up @@ -224,10 +223,9 @@ public void queryVectorsWithYield() {

@Test
public void queryVectorsWithFilter() {
testResult(db, """
CALL apoc.vectordb.weaviate.query($host, 'TestCollection', [0.2, 0.1, 0.9, 0.7],
'{operator: Equal, valueString: "London", path: ["city"]}',
5, $conf) YIELD metadata, id RETURN * ORDER BY id""",
testResult(db, "CALL apoc.vectordb.weaviate.query($host, 'TestCollection', [0.2, 0.1, 0.9, 0.7],\n" +
" '{operator: Equal, valueString: \"London\", path: [\"city\"]}',\n" +
" 5, $conf) YIELD metadata, id RETURN * ORDER BY id",
map("host", HOST, "conf", map(ALL_RESULTS_KEY, true, "fields", FIELDS, HEADERS_KEY, ADMIN_AUTHORIZATION)),
r -> {
assertLondonResult(r.next(), ID_2, FALSE);
Expand All @@ -236,8 +234,7 @@ public void queryVectorsWithFilter() {

@Test
public void queryVectorsWithLimit() {
testResult(db, """
CALL apoc.vectordb.weaviate.query($host, 'TestCollection', [0.2, 0.1, 0.9, 0.7], null, 1, $conf) YIELD metadata, id RETURN * ORDER BY id""",
testResult(db, "CALL apoc.vectordb.weaviate.query($host, 'TestCollection', [0.2, 0.1, 0.9, 0.7], null, 1, $conf) YIELD metadata, id RETURN * ORDER BY id",
map("host", HOST, "conf", map(ALL_RESULTS_KEY, true, "fields", FIELDS, HEADERS_KEY, ADMIN_AUTHORIZATION)),
r -> {
assertBerlinResult(r.next(), ID_1, FALSE);
Expand Down
Loading

0 comments on commit d15f7e5

Please sign in to comment.