Forceful Overwrite of documents

20 views
Skip to first unread message

Gaurav Kumar

unread,
Apr 11, 2016, 7:37:03 AM4/11/16
to ArangoDB
Hi folks,

I am using the Java driver and was wondering how I could overwrite a document regardless of whether it exists or not. In ElasticSearch, when I index a document, it gets replaced if it exists, else it simply gets indexed. In ArangoDB using Java driver, either I can create a document or I can replace it. So, I'll have to try to create a document, if if fails, issue a replace on it. Is there a better way? I searched for it and found UPSERT AQL command. Is using AQL in java driver recommended or using the native createDocument interface better for performance while bulk indexing?

Thanks,
GK

Wilfried Gösgens

unread,
Apr 11, 2016, 7:57:14 AM4/11/16
to ArangoDB
Hi,
Sorry for overreading your question on Slack.

If you want to insert many documents at once, using the batch API and taking care of those that failed is the way to go.

With UPSERT you will only be able to insert one document at a time, which can't be as fast as the batch api.

But you're right, one may want to overwrite documents, I'll add this as a feature request.

Cheers,
Willi

Wilfried Gösgens

unread,
Apr 11, 2016, 8:00:58 AM4/11/16
to ArangoDB

Gaurav Kumar

unread,
Apr 11, 2016, 8:11:24 AM4/11/16
to ArangoDB
Thanks Willi for posting the feature request.
Given the current state of affairs, I think the best way would be to use batch API to insert documents. Then issue another batch API for replacing the documents which failed to insert.

Wilfried Gösgens

unread,
Apr 11, 2016, 8:18:34 AM4/11/16
to ArangoDB
Yes,
Exeactly thats what I was trying to say ;-)
Reply all
Reply to author
Forward
0 new messages