Thanks for the explanation. I have always (mistakenly) thought of the type of the relationship as a sort of property.
In any case, the script seems to work quite nicely, and is easy to autogenerate the parameters for from Assimilation discovery information. I discovered something surprising (a bug?) about curl -- unless I give it the -g flag (don't expand globs), then it doesn't like ipv6 IP/port combinations - like [::ffff:127.0.0.1]:7474. IMHO, it shouldn't be trying to glob IP addresses... I noticed that neo4j doesn't appear to be ipv6 compliant (i.e., it doesn't listen on '::'). Is that intentional? In any case, the script seems to give neo4j some trivial, but meaningful exercise. You have to parse the query, optimize it, create a query plan, execute it, walk through the results, convert them to JSON and send them back out the REST interface. Quite a few things have to be working for it to succeed. Do you have a favorite trivial query that will succeed in any non-empty neo4j database? Do you have a better grep pattern for matching correct output? On 12/17/2013 11:18 PM, Michael Hunger wrote: > return type(r) > > Empty curly braces mean no props > > Sent from mobile device > > Am 18.12.2013 um 06:41 schrieb Alan Robertson <[email protected]>: > >> The query in the script below produces the following output: >> {"results":[{"columns":["one","rel","two"],"data":[{"row":[{"domain":"metadata","nodetype":"CMAclass","name":"HbRing"},{},{"domain":"metadata","nodetype":"CMAclass","name":"CMAclass"}]}]}],"errors":[]} >> >> What I noticed is that the relationship shows up as {}. Do I need to >> change the query to get the relationship type? [See the script below >> for the query] >> >> In any case, below is a script which does a passable job of seeing if >> Neo4j is operational (and not dead, comatose, or laying on the ground >> twitching)... I'm going to write an OCF resource agent using it - so I >> can monitor neo4j "properly". And I could also make it highly-available >> using Pacemaker... >> >> It can use either wget or curl to talk to Neo4j. >> >> # >> # Simple script to monitor Neo4j for basic operation >> # >> # Potential inputs to this script are: >> # ipport: IP-port combination of the neo4j REST server >> # cypher: Cypher query string >> # regex: Regular expression to match server output against >> # grepflags: flags to give grep >> ipport='127.0.0.1:7474' >> ipport='[::ffff:127.0.0.1]:7474' >> cypher="START one=node(*) RETURN one LIMIT 1" >> # Need at least one node and one relationship for this one to succeed... >> cypher="START one=node(*) MATCH one-[rel]->two RETURN one, rel, two LIMIT 1" >> regex='^{ *"results" *: *\[.*\] *, *"errors" *: *\[ *\] *}$' >> grepflags="" >> # >> # Other variables in the script >> # queryjson: JSON-encapsulated version of cypher query >> # committrans: url suffix for committing transactions in one go >> # URL: URL to give to Neo4j REST service >> # header: Extra header information to give REST service (i.e., >> Content-type) >> queryjson="{\"statements\" : [ { \"statement\" : \"$cypher\" } ] }" >> committrans='db/data/transaction/commit' >> URL=http://${ipport}/${committrans} >> header='Content-type: application/json' >> use_wget=1 >> >> runquery() { >> if >> [ "$use_wget" -eq 1 ] >> then >> wget -q --header="${header}" --post-data="$queryjson" >> --output-document=- $URL >> else >> curl -s -g --header "${header}" --data "$queryjson" --output >> - $URL >> fi >> } >> monitor() { >> runquery | grep ${grepflags} "${regex}" >/dev/null >> } >> runquery >> monitor >> rc=$? >> echo $rc >> exit $rc >> >> >> >> -- >> Alan Robertson <[email protected]> - @OSSAlanR >> >> "Openness is the foundation and preservative of friendship... Let me claim >> from you at all times your undisguised opinions." - William Wilberforce >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Neo4j" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. -- Alan Robertson <[email protected]> - @OSSAlanR "Openness is the foundation and preservative of friendship... Let me claim from you at all times your undisguised opinions." - William Wilberforce -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
