Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to mongodb #106

Closed
ghost opened this issue Aug 8, 2014 · 12 comments
Closed

Connecting to mongodb #106

ghost opened this issue Aug 8, 2014 · 12 comments

Comments

@ghost
Copy link

ghost commented Aug 8, 2014

I have tried to configure cayley to use mongodb: cayley http --config=cayley.cfg.test --port=64211 where cayley.cfg.test is:
{ "database": "mongodb", "db_path": "localhost/test:27017" }
but i get an error: F0808 12:43:02.479565 06352 cayley.go:137] triplestore: name 'mongodb' is not registered.

@miku
Copy link

miku commented Aug 8, 2014

The name under which the MongoDB backend registers itself is just mongo.

@ghost
Copy link
Author

ghost commented Aug 8, 2014

Thanks! mongo works, but a bit confusing since the docs says mongodb.

However, now when I write the testdata.nq data and perform a query, e.g.: g.V("alice").All(), I get an empty result {"result": [{"id": ""}]} and an error: E0808 14:35:12.924594 06501 triplestore.go:257] Error: Couldn't retrieve node 48181acd22b3edaebc8a447868a7df7ce629920a not found. If I look in the mongodb collection I find the triplet data. When storing data in memory I get the correct result response and dont get the error.

@kortschak
Copy link
Contributor

Would you please post the version of cayley you are using and the complete sequence of commands you used to init and load the db.

@barakmich
Copy link
Member

Also, sidenote, either the documentation should be "mongo" or the registry should be "mongodb" -- I'd vote to do the latter because that's the official name.

@barakmich
Copy link
Member

Tried it against my docker-mongo with the config you posted, without a problem. Seconded for finding the relevant commands.

@ghost
Copy link
Author

ghost commented Aug 8, 2014

Thought I was using version 0.3.1, but cayley version says Cayley snapshot (installed via homebrew)? Mongodb version 2.4.9. 1) Run cayley http --config=cayley.cfg.test --port=64211 with config above no init/load. 2) Load the testdata.nq through the UI, data loaded and found in mongodb. 3) Close the process. 4) restart cayley http --config=cayley.cfg.test --port=64211. 5) Run query: g.V("alice").All() -> error: E0808 22:39:21.150600 21815 triplestore.go:257] Error: Couldn't retrieve node 522b276a356bdf39013dfabea2cd43e141ecc9e8 not found. There seems to be an something going on with the parsing because the "alice" entry is stored as "\u003calice\u003e"?

@barakmich
Copy link
Member

Hmm. That looks like smart quotes. Which aren't special to cquads and will be part of the string.

If you use the 0.3.1 release version for OS X (darwin_amd64, I'm guessing), what happens? If it's the same issue, then there's something weird in parsing/HTTP. If it works, there's something wrong with the Homebrew package.

kortschak added a commit to kortschak/cayley that referenced this issue Aug 9, 2014
@kortschak
Copy link
Contributor

The http parser uses nquad which leaves N-Quad quotes in the quad.Quud strings. This must be left over from previously. I don't understand why memstore works correctly then though.

We should make this configurable in the web UI, but I have pushed something that should fix this problem in the short term.

@steindani
Copy link

For me Cayley 0.3.1 also imports nodes starting with \0003c (unicode less-than sign <) and endig with \u003e (greater-than sign >). Both using the web UI and sending the file to the Cayley server.

If the nt/nq file is loaded with the ./cayley http --dbpath= command, it is parsed correctly, without the < > characters. The nodes imported later into this DB also begin with \003c.

Both

  • web UI and HTTP load,
  • memstore and mongodb

has this problem.

(I used 0.3.0 with TTL format without problem.)

@kortschak
Copy link
Contributor

I'm not sure what you mean by HTTP load doesn't work if you say that cayley http --dbpath=<file> gives you expected results, but yes, the problem was AFAICS in the UI code, not in the mongo interface. The change at 614184b should fix this. Are you able to test whether you still have a problem if you use the current tip (aad21b0)?

@steindani
Copy link

By HTTP load I mean uploading the nt file to /api/v1/write/file/nquad. After pulling the latest version of the repository, the nt files are imported correctly. Thank you!

@barakmich
Copy link
Member

Closing as fixed (esp. in the next binary)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants