Skip to content

Commit b3791a3

Browse files
authored
Update docs to include upsert vector examples and add supported versions to docs (neo4j#74)
* Add upsert_data example to docs/ * Add supported python and neo4j version
1 parent 7c24e70 commit b3791a3

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ fast to ship new features and high performing patterns and methods.
88

99
Documentation: https://neo4j.com/docs/neo4j-genai-python/
1010

11+
Python versions supported:
12+
13+
* Python 3.12 supported.
14+
* Python 3.11 supported.
15+
* Python 3.10 supported.
16+
* Python 3.9 supported.
17+
* Python 3.8 supported.
18+
1119
# Usage
1220

1321
## Installation
@@ -54,14 +62,13 @@ create_vector_index(
5462

5563
### Populating the Neo4j Vector Index
5664

57-
This library does not provide functionality to write data to the database.
58-
See below for how to do this using [the Neo4j Python driver](https://github.com/neo4j/neo4j-python-driver).
65+
Note that the below example is not the only way you can upsert data into your Neo4j database. For example, you could also leverage [the Neo4j Python driver](https://github.com/neo4j/neo4j-python-driver).
5966

6067
Assumption: Neo4j running with a defined vector index
6168

6269
```python
6370
from neo4j import GraphDatabase
64-
from random import random
71+
from neo4j_genai.indexes import upsert_query
6572

6673
URI = "neo4j://localhost:7687"
6774
AUTH = ("neo4j", "password")
@@ -70,18 +77,13 @@ AUTH = ("neo4j", "password")
7077
driver = GraphDatabase.driver(URI, auth=AUTH)
7178

7279
# Upsert the vector
73-
vector = [random() for _ in range(DIMENSION)]
74-
insert_query = """
75-
MERGE (n:Document {id: $id})
76-
WITH n
77-
CALL db.create.setNodeVectorProperty(n, 'vectorProperty', $vector)
78-
RETURN n
79-
"""
80-
parameters = {
81-
"id": 0,
82-
"vector": vector,
83-
}
84-
driver.execute_query(insert_query, parameters)
80+
vector = ...
81+
upsert_query(
82+
driver,
83+
node_id=1,
84+
embedding_property="vectorProperty",
85+
vector=vector,
86+
)
8587
```
8688

8789
### Performing a similarity search

docs/source/index.rst

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ The purpose of this package is to provide a first party package to developers,
1212
where Neo4j can guarantee long term commitment and maintenance as well as being
1313
fast to ship new features and high performing patterns and methods.
1414

15+
Neo4j versions supported:
16+
17+
* Neo4j >=5.18.1
18+
* Neo4j Aura >=5.18.0
19+
20+
Python versions supported:
21+
22+
* Python 3.12
23+
* Python 3.11
24+
* Python 3.10
25+
* Python 3.9
26+
* Python 3.8
27+
28+
1529
******
1630
Topics
1731
******
@@ -93,14 +107,13 @@ See :ref:`the API documentation<create-vector-index>` for more details.
93107
Populating the Neo4j Vector Index
94108
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95109

96-
This library does not provide functionality to write data to the database.
97-
See below for writing data using `the Neo4j Python driver <https://github.com/neo4j/neo4j-python-driver>`_.
110+
Note that the below example is not the only way you can upsert data into your Neo4j database. For example, you could also leverage `the Neo4j Python driver <https://github.com/neo4j/neo4j-python-driver>`_.
98111

99112

100113
.. code:: python
101114
102115
from neo4j import GraphDatabase
103-
from random import random
116+
from neo4j_genai.indexes import upsert_query
104117
105118
URI = "neo4j://localhost:7687"
106119
AUTH = ("neo4j", "password")
@@ -109,18 +122,13 @@ See below for writing data using `the Neo4j Python driver <https://github.com/ne
109122
driver = GraphDatabase.driver(URI, auth=AUTH)
110123
111124
# Upsert the vector
112-
vector = [random() for _ in range(DIMENSION)]
113-
insert_query = """
114-
MERGE (n:Document {id: $id})
115-
WITH n
116-
CALL db.create.setNodeVectorProperty(n, 'vectorProperty', $vector)
117-
RETURN n
118-
"""
119-
parameters = {
120-
"id": 0,
121-
"vector": vector,
122-
}
123-
driver.execute_query(insert_query, parameters)
125+
vector = ...
126+
upsert_query(
127+
driver,
128+
node_id=1,
129+
embedding_property="vectorProperty",
130+
vector=vector,
131+
)
124132
125133
126134
.. note::

0 commit comments

Comments
 (0)