Reputation: 43
In the Neo4j browser, I can write :SCHEMA
to get the list of indexes in a db. Using http, you can do something like curl http://localhost:7474/db/data/schema/index/
, which I can pythonize with
import requests
r = requests.get('http://localhost:7474/db/data/schema/index/')
r.json()
Can I do something equivalent through the bolt protocol? requests
can't handle it (InvalidSchema: No connection adapters were found for 'bolt://...'
), and since :SCHEMA
isn't valid cypher, neither session.run(':SCHEMA')
nor session.run('SCHEMA')
work.
I can't use http
because I won't have access to the http
port in my application (although requests via http
seem to be broken anyway).
Upvotes: 3
Views: 310
Reputation: 2507
You can use session.run('CALL db.constraints()')
and session.run('CALL db.indexes()')
to get the two components of the schema. You (I believe, if there's a better way someone please correct me) will have to parse the strings inside the result cells if you want to track them programatically.
Upvotes: 2