Neo4j Error - There is no such fulltext schema index: entity
Opened this issue · 3 comments
I am getting an error with the graph_retriver function where the fulltext search is being done. The method
db.index.fulltext.queryNodes("entity", $query, {limit:2})
returns an error saying that :
There is no such fulltext schema index: entity.
The full error reads
ClientError: {code: Neo.ClientError.Procedure.ProcedureCallFailed} {message: Failed to invoke procedure
db.index.fulltext.queryNodes
: Caused by: java.lang.IllegalArgumentException: There is no such fulltext schema index: entity}.
add this code before querying:
from neo4j import Driver
def initialize_fulltext_index(driver: Driver):
with driver.session() as session:
# Check if the index exists
session.run("CREATE FULLTEXT INDEX entity IF NOT EXISTS FOR (n:Document) ON EACH [n.text]")
# logger.info("Fulltext index 'entity' created or already exists")
# Initialize Neo4j driver
neo4j_driver = GraphDatabase.driver("neo4j://localhost:7687", auth=("neo4j", "your_password"))
# Initialize fulltext index
initialize_fulltext_index(neo4j_driver)
@misteral I tried to call your code before querying, but it does not help either. I still get the same error as before.
For me, it's solving the problem but the output is wired:
41e2d6cbaac3f75505bb42104013424b - MENTIONS -> Nonna Lucia
c7c1a9c073ded36181b0e59f17e4ff40 - MENTIONS -> Caruso Family
c7c1a9c073ded36181b0e59f17e4ff40 - MENTIONS -> Antonio
c7c1a9c073ded36181b0e59f17e4ff40 - MENTIONS -> Amico
c7c1a9c073ded36181b0e59f17e4ff40 - MENTIONS -> Lucia