Just to follow up and get some data out of the index ...
import os, re
import simplejson as json
def match(s, reg):
p = re.compile(reg, re.IGNORECASE| re.DOTALL)
results = p.findall(s)
return results
def get_data(response_data):
' Avoids the headers'
regex = '\r\n\r\n(.*)'
results = match(response_data, regex)
return results[0]
def get_node_from_index(index_name, property_value,property_name='name' ):
curl_str = '''curl -i -s -H Accept:application/json
'http://localhost:7474/db/data/index/node/%s/%s/%s' ''' % (index_name,
property_name, property_value)
print curl_str
response = os.popen( curl_str )
#print "Errors", response.errors
data = response.read( )
json_data = get_data(data)
python_data = json.loads(json_data)
return python_data
...produces...
curl -i -s -H Accept:application/json
'http://localhost:7474/db/data/index/node/medical/name/Hospitality_Recreation'
[{'traverse': 'http://localhost:7474/db/data/node/29/traverse/{returnType}',
'create_relationship': 'http://localhost:7474/db/data/node/29/relationships',
'self': 'http://localhost:7474/db/data/node/29',
'outgoing_typed_relationships':
'http://localhost:7474/db/data/node/29/relationships/out/{-list|&|types}',
'all_typed_relationships':
'http://localhost:7474/db/data/node/29/relationships/all/{-list|&|types}',
'all_relationships': 'http://localhost:7474/db/data/node/29/relationships/all',
'outgoing_relationships':
'http://localhost:7474/db/data/node/29/relationships/out',
'incoming_typed_relationships':
'http://localhost:7474/db/data/node/29/relationships/in/{-list|&|types}',
'indexed':
'http://localhost:7474/db/data/index/node/medical/name/Hospitality_Recreation/29',
'extensions': {'DepthTwo': {'nodesOnDepthTwo':
'http://localhost:7474/db/data/ext/DepthTwo/node/29/nodesOnDepthTwo',
'relationshipsOnDepthTwo':
'http://localhost:7474/db/data/ext/DepthTwo/node/29/relationshipsOnD
epthTwo', 'pathsOnDepthTwo':
'http://localhost:7474/db/data/ext/DepthTwo/node/29/pathsOnDepthTwo'},
'ShortestPath': {'shortestPath':
'http://localhost:7474/db/data/ext/ShortestPath/node/29/shortestPath'}},
'incoming_relationships':
'http://localhost:7474/db/data/node/29/relationships/in', 'property':
'http://localhost:7474/db/data/node/29/properties/{key}', 'data': {'type':
'tag', 'name': 'Hospitality_Recreation'}, 'properties':
'http://localhost:7474/db/data/node/29/properties'}]
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user