Can't get Neo4jVector.from_existing_index to work

I am using langchain_community.vectorstores.neo4j_vector to create embeddings directly in a graph, then run similarity queries.
It works ok using Neo4jVector.from_existing_graph:

  • create the embeddings
  • search similarities for "question"
    But I get error when I try to use again the created index with :
    Neo4jVector.from_existing_index
    the code:

from langchain_community.vectorstores.neo4j_vector import Neo4jVector

vector_index = Neo4jVector.from_existing_graph(
url=NEO4J_DB_URI,
username=NEO4J_DB_USERNAME,
password=NEO4J_DB_PWD,
embedding=embeddings_model,
index_name='myVectorIndex',
node_label='myTable',
text_node_properties=['att1', 'att2'],
embedding_node_property='myEmbeddings',
)

response = vector_index.similarity_search(question) -> works ok :ok_hand:

run the code again to fetch the existing index:

vector_index = Neo4jVector.from_existing_index(
url=NEO4J_DB_URI,
username=NEO4J_DB_USERNAME,
password=NEO4J_DB_PWD,
embedding=embeddings_model,
index_name='myVectorIndex',
)

response = vector_index.similarity_search(question) -> error

Exception has occurred: ValueError
Make sure that none of the `text` properties on nodes with label `myTable` are missing or empty

Looking at the details of the returned vector_index
it looks by default for text_node_properties = 'text' which of course doesn't exist.
and text_node_properties is not expected in Neo4jVector.from_existing_index

You've probably got to make explicit which attribute should be considered as text, in the "retrieval_query":

...
RETURN <node.attribute> AS text,
score,
node {...} AS metadata

where the <node.attribute> mentioned above has been/is used to compute the embeddings, by means of the embedding model considered.

Also you may have to condition:

WHERE <node.attribute> is NOT NULL

to avoid further errors.