Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-16-2021 09:33 AM
Please forgive my Cypher
newbie ignorance -- even after a year and a half, I just do not grok how Cypher
returns results.
The task at hand is to export a .json
file whose contents are the result of SHOW INDEXES
. Presumably I can use the same approach to create another .json
file containing the result of SHOW CONSTRAINTS
.
I sort-of understand how to use MATCH
and MERGE
to provide temporary variable names that I can pass along using WITH
and RETURN
. I find nothing in the documentation for SHOW INDEXES
that indicates the type and use of its results.
I'm hoping that one of you can provide a Cypher
string that emits the results of SHOW INDEXES
to a JSON file. I've tried a few alternatives and I clearly don't understand what's going on.
11-22-2021 10:03 AM
Hi tms,
I use this to output my indexes in a json format, I then save the results to a .json file in my code, you can also just copy the results and paste them in a json file.
I am only "yielding" the fields that I found useful, but there are a few others that you could pull.
call db.indexes() yield name, type, labelsOrTypes, properties
WITH *
ORDER BY labelsOrTypes[0]
WITH COLLECT({name:name, type:type, labelsOrTypes:labelsOrTypes, properties:properties}) as results
return apoc.convert.toJson(results) as results
The results look like this:
[
{
"name": "my_index_name",
"labelsOrTypes": [
"MyNodeLabel"
],
"type": "BTREE",
"properties": [
"my_indexed_prop"
]
}
]
Hope that helps
All the sessions of the conference are now available online