Hi, Community!
First of all a want to say thanks, everybody for reading my post,
there will be a lot of questions. I'm Russian web-developer (sorry for
my English, please correct my mistakes) and half of year I'm looking
forwards to NoSQL databases, the reason was that one of my project is
using semantics data, and relational DB doesn't meet the requirements.
I will write my actions in timeline order, and there will be q.
1. I read a lot of documentations about neo4j, and found that it could
be implemented with my loveliest present lang - python
2. First of all I tried to use neo4j.py (throug JPypi), but I faced
problem with building, after some time found that I had not properly
installed JDK on my Ubuntu 9.1, reinstalling solved build problems,
but the library still doesn't want to work, and I can't figure out
what's wrong, everything is built but when I'm trying to run:
logger = logging.getLogger('neo')
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
graphdb = neo4j.GraphDatabase("/path/to/staroge", log=logger)
"/path/to/staroge" is writable, but Jpype backend fails, and I have no Idea :'(
raises exception:
classpath is:
['/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/classes/geronimo-jta_1.1_spec.jar',
'/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/classes/neo4j-kernel.jar',
'/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/classes/lucene-core.jar',
'/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/classes/neo4j-index.jar',
'/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/classes/junit.jar',
'/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/classes/neo4j-remote-graphdb.jar',
'/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/classes/neo4j-commons.jar']
ext_dirs is:
['/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/classes']
Trying JCC backend.
Trying JPype backend.
/usr/local/lib/python2.6/dist-packages/jpype/_pykeywords.py:18:
DeprecationWarning: the sets module is deprecated
import sets
Importing native backends failed.
Traceback (most recent call last):
File
"/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/_backend/__init__.py",
line 51, in initialize
embedded, remote = implementation.initialize(classpath, params)
File
"/usr/local/lib/python2.6/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.6.egg/neo4j/_backend/reflection.py",
line 44, in initialize
jvm = jpype.getDefaultJVMPath()
File "/usr/local/lib/python2.6/dist-packages/jpype/_core.py", line
96, in getDefaultJVMPath
return _linux.getDefaultJVMPath()
File "/usr/local/lib/python2.6/dist-packages/jpype/_linux.py", line
36, in getDefaultJVMPath
jvm = _getJVMFromJavaHome()
File "/usr/local/lib/python2.6/dist-packages/jpype/_linux.py", line
55, in _getJVMFromJavaHome
if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Trying pure Python backend.
2. "Ok" - I said to myself, and I decided to use REST server, I was
glad that it runs in single instance, and doesn't needs to stop and
start for every web request,
Q: AS I understand that using neo4j.py with DJANGO I will run a new
JVM every request, am I right ? Or nor ?
3. Using REST is wonderful and it is suite me with 80% of
requirements, other 20% I decided to emulate.
for example:
- To sync deferent user requests with DB, for update/insert/delete
operations I've decide to do a queue in a relational db, that will
perform step by step operations, so some part of Transactions was
solved
- I'v wrote a little daemon that picks a task and runs a command.
- Also I'v created some tests with NetworkX and Graphiz that helps me
with visualisation of query result
4. Python REST implemention is good but it lacks with some traversing
and indexing functions.
- I'v tried to make some custom queries like:
data = {
"order": "depth first",
"uniqueness": "node path",
"relationships": [
{ "type": "USER", "direction": "out" },
{ "type": "OWNES", "direction": "out" },
{ "type": "USES", "direction": "out" },
{ "type": "CONTAINS", "direction": "out" },
],
"prune evaluator": {
"language": "javascript",
"body": "if(position.node().hasProperty('username')){\
if(position.node().getProperty('username').equals('sergey')){\
false;\
}else{\
true;\
}\
}else{\
false;\
}"
},
response = Request().post(url, data=data)
if response.status == 200:
content = response.body
return simplejson.loads(content)
else:
print response.body
Q: first of all I'v faced a lot of problems with "prune evaluator"
1. I did not found the best way to debug javascript, only "throw"
inside body can tell me something about var or an object.
2. It seems that it is impossible comparisons with relations, maybe
there is something else but for ex.
...
position.node().getRelations() //returns []
....
Q: Also it seems impossible to check has current node certain relation
or not, is it true ?
...
enum MyRelationshipTypes implements RelationshipType{\
CONTAINED_IN, KNOWS\
}\
...
Q: how can I instantiate the RelationshipType inside javascript body,
or maybe I need to use another script engine ? It would be nice if
there will be !MORE! examples about REST traversing, it is very
powerful tool.
Q: Please who are able, help me with neo4j start, I think I messed up
something, may be you'll suggest to read some links, or simply help me
with some examples.
Q: Maybe it would wiser to learn Java and "Springs" instead of
tricking with Python, Django and REST
Q: *Dummy question* If it would be a java, could somebody explain me
the bases work with "springs", the main question is: "Would be spring
web-application work as a single instance, or I'll need to start and
stop neo4j engine every request ? "
--
Best Regards, Nikitin Sergey
ICQ 343833010
phone: +79260135566
site: http://nikitinsm.ru
email: [email protected]
skype: nikitinsm
jabber: [email protected]
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user