Comments (15)
@sajeevpr you may also be interested in https://groups.google.com/forum/#!topic/arangodb/fg7OoRW8Ltc - If you like it, @virmundi will probably appreciate feedback.
from arangodb-java-driver.
Hi Sajeev,
we have some test-code that could help you:
https://github.com/arangodb/arangodb-java-driver/blob/master/src/test/java/com/arangodb/ArangoDriverImportTest.java
Please, feel free to join our slack-community.
https://slack.arangodb.com/
Regards,
Mark
from arangodb-java-driver.
Thank you for the docs.
But I tried the following scenario.
- updated one doc. I was able to see the document updated using GUI.
- Deleted the same doc manually from the GUI
- inserted the same doc using java import api
But I am unable to see the document in GUI or using AQL.
So what could be the problem here.
I am seeing more dead documents after using import api.
But when I accessed like below, the document shows up.
http://:/_db/_system/_admin/aardvark/index.html#collection/Accounts/2293446076
I am using the code like below
ImportOptions options = new ImportOptions();
options.setOnDuplicate(OnDuplicate.REPLACE);
ImportResultEntity result = driver.importDocumentsByHeaderValues("Accounts", accountListForGraphDB,options);
Regards,
Sajeev
from arangodb-java-driver.
Hi Sajeev,
we would need a bit better to reproduce sequence in order to reproduce this.
We tried using arangosh + the webinterface: (we also tried java, however there should be no difference in the end)
db._create('test')
db.test.save({'_key': 'foo' , 'bla': 'bar'})
go into the collection tab, click test, document there; delete it in the webinterface.
db.test.save({'_key': 'foo' , 'bla': 'bar'})
press F5 in the browser, foo
back again.
db._query('UPDATE "foo" WITH { blarg: "blub"} IN test')
delete in the browser
db.test.save({'_key': 'foo' , 'bla': 'bar'})
press F5 in the browser, foo
back again
Any better hints how to reproduce this?
from arangodb-java-driver.
@dothebart , The issue is coming when I tried using the import api given in the java driver.
ImportResultEntity result = driver.importDocumentsByHeaderValues("Accounts", accountListForGraphDB,options);
Regards,
Sajeev
from arangodb-java-driver.
But updateDocument and createDocument given in the java driver is working perfectly. In this case, I need to put all my documents in a loop, then do a check whether the document exists or not and then do an insert or update.
from arangodb-java-driver.
The sequence is like this.
update document A
Delete document A
Insert document A
Query document A - This fails
from arangodb-java-driver.
Hi Sajeev,
I wrote a little test for your case. In my environment It runs without failures. Can you tell me, what I have to do, so that it fails?
package com.arangodb;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import com.arangodb.entity.DocumentEntity;
import com.arangodb.util.ImportOptions;
import com.arangodb.util.MapBuilder;
public class ImportDocumentTest {
private static final String COLLECTION_NAME = "test";
private static final String KEY = "foo";
private static ArangoConfigure configure;
private static ArangoDriver driver;
@BeforeClass
public static void setup() {
configure = new ArangoConfigure();
configure.init();
driver = new ArangoDriver(configure);
try {
driver.deleteCollection(COLLECTION_NAME);
} catch (final ArangoException e) {
}
try {
driver.createCollection(COLLECTION_NAME);
} catch (final ArangoException e) {
}
}
@AfterClass
public static void cleanup() {
try {
driver.deleteCollection(COLLECTION_NAME);
} catch (final ArangoException e) {
}
configure.shutdown();
}
@SuppressWarnings("rawtypes")
@Test
public void process() throws ArangoException {
// initial create the document
driver.createDocument(COLLECTION_NAME, new MapBuilder().put("_key", KEY).put("bla", "bar").get());
// update the document
driver.updateDocument(COLLECTION_NAME + "/" + KEY, new MapBuilder().put("blarg", "blub").get());
// delete the document
driver.deleteDocument(COLLECTION_NAME + "/" + KEY);
// import same document
final ImportOptions options = new ImportOptions();
final Collection<Collection<?>> headerValues = new ArrayList<Collection<?>>();
headerValues.add(Arrays.asList("_key", "bla", "blarg"));
headerValues.add(Arrays.asList(KEY, "bar", "blub"));
driver.importDocumentsByHeaderValues(COLLECTION_NAME, headerValues, options);
// get the document
final DocumentEntity<Map> doc = driver.getDocument(COLLECTION_NAME + "/" + KEY, Map.class);
Assert.assertFalse(doc.isError());
Assert.assertEquals(COLLECTION_NAME + "/" + KEY, doc.getDocumentHandle());
Assert.assertEquals("bar", doc.getEntity().get("bla"));
Assert.assertEquals("blub", doc.getEntity().get("blarg"));
// query the document via AQL
final String query = "RETURN DOCUMENT(@docHandle)";
final Map<String, Object> bindVars = new MapBuilder().put("docHandle", COLLECTION_NAME + "/" + KEY).get();
final DocumentCursor<Map> result = driver.executeDocumentQuery(query, bindVars, null, Map.class);
final DocumentEntity<Map> uniqueResult = result.getUniqueResult();
Assert.assertNotNull(uniqueResult);
Assert.assertEquals(COLLECTION_NAME + "/" + KEY, uniqueResult.getDocumentHandle());
Assert.assertEquals("bar", uniqueResult.getEntity().get("bla"));
Assert.assertEquals("blub", uniqueResult.getEntity().get("blarg"));
}
}
from arangodb-java-driver.
Hi @mpv1989 ,
This code is working for me as well. Let me dig little deeper.
One thing I noted was after adding one document to the collection, I can see the Alive and dead objects both as 0. What does this mean?
Regards,
Sajeev
from arangodb-java-driver.
Hi @mpv1989 ,
Apologies, the issue was not there.
I mistakenly used String data type for indexing the document and then queried it like integer.
Its working now, when I index as Object data type for all fields.
Thank you for your time.
Regards,
Sajeev
from arangodb-java-driver.
can you modify my example, so it reproduces the pitfall you steped in?
from arangodb-java-driver.
@mpv1989 , I didn't exactly followed your program. Please find below the snippet which can explain the problem.
//Updating the document
List<List<?>> values = new ArrayList<List<?>>();
values.add(Arrays.asList("_key","firstName", "lastName", "age", "gender"));
values.add(Arrays.asList("test1","Joe", "Public", 42, "male", 10)); // error
values.add(Arrays.asList("test2","Jane", "Doe", 31, "female"));
ImportOptions options = new ImportOptions();
options.setOnDuplicate(OnDuplicate.UPDATE);
final ImportResultEntity result = driver.importDocumentsByHeaderValues(UT_IMPORT_TEST, values,options);
//Updating the same document with age given as string
List<List<?>> values = new ArrayList<List<?>>();
values.add(Arrays.asList("_key","firstName", "lastName", "age", "gender"));
values.add(Arrays.asList("test1","Joe", "Public", "42", "male", 10)); // error
values.add(Arrays.asList("test2","Jane", "Doe", "31", "female"));
//Query age as just 42 or 32 will show no records, but document will come up if we query with "42" or "32"
from arangodb-java-driver.
thank you.
from arangodb-java-driver.
when you import documents, you can check if there was an error at one of them. With getErrors() In the ImportResultEntity you can find the number of documents where an error happend via importing.
from arangodb-java-driver.
ok. Thank you. I have incorporated that.
from arangodb-java-driver.
Related Issues (20)
- Please package with maven-bundle-plugin HOT 1
- Q: Default value HOT 5
- Why does you not throw ArangoDBException in HttpCommunication.java, the inserting action was failed but I cannot handle this event HOT 2
- InternalSerdeImpl does not serialize bindVars correctly HOT 2
- Version 7: How to ignore POJO fields for arangodb but serialize for outgoing as JSON with jackson HOT 4
- Interfering Jackson annotations HOT 2
- Arango query is flattening nested attributes HOT 3
- Exception thrown by cursor when query results > batch size (v6.18.0+) HOT 5
- "vertx-blocked-thread-checker" java.lang.OutOfMemoryError HOT 2
- ROUND_ROBIN fallback not working HOT 3
- Synchronous streaming batched cursor throws exception when attempting to close after last batch is consumed HOT 1
- [DE-55] Retry case of error 503(without 'x-arango-endpoint') HOT 1
- [question] maxConnections parameter for 7.x.x arango client greater than 1 HOT 2
- Cursor with multiple batches is closed twice HOT 2
- Dependency upgrade for vertx to 4.5.3 (CVE-2024-1023) HOT 1
- Slow performance for large datasets on 7.5.1 (via Spring Data 4.1.0) HOT 4
- returnNew not working with ArangoCollectionAsync.insertDocuments method HOT 2
- Graalvm native build error HOT 2
- [DE-535] Provide the capability to reuse an existing Vertx instance HOT 1
- Quarkus native: No JsonFactory found for content type: JSON HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arangodb-java-driver.