ArangoDB-Community / arangodb-tinkerpop-provider

An implementation of the Tinkerpop OLTP Provider for ArangoDB
Apache License 2.0
84 stars 16 forks source link

How to import data in ArangoDB through ArangoDB-Tinkerpop-Provider-API? #75

Closed mselite closed 2 years ago

mselite commented 2 years ago

There is a way to import data into ArangoDB through TinkerPop API? As I can't exploit existing ArangoDB. In fact, I can connect to existing ArangoDB DB through Tinkerpop API and it create me an additionaly collection "TINKERPOP-GRAPH-VARIABLES", but I can't do any process with that DB through Tinkerpop API. For example with AQL I can get result of this query:

for v in nodes
filter v.title == "Journal 1 (1940)"
return v.issued

But with the Tinkerpop API the output is empty, here is my sample code:

      public class arangoDBConnexion {
          public static void main(String[] args) {
              try {
                  Configuration config = new PropertiesConfiguration("config.properties");
                  ArangoDBGraph graph = ArangoDBGraph.open(config);
                  GraphTraversalSource gts = new GraphTraversalSource(graph);
                  GraphTraversalSource g = gts.clone();
                  System.out.println("Connect to Database: " + graph.toString());

                  g = gts.clone();
                  List<Object> name = g.V().has("Journal","title","Journal1(1940)").values("issued").toList();
                  System.out.println("Query result: " + name);

                  // close the graph and the traversal source
                  gts.close();
                  graph.close();
              } catch (final ConfigurationException e) {
                  e.printStackTrace();
              } catch (Exception e) {
                  e.printStackTrace();
              }

          }
      }

Here is the configuration file:

  gremlin.graph = com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph
  gremlin.arangodb.conf.graph.shouldPrefixCollectionNames = false
  gremlin.arangodb.conf.graph.db = test
  gremlin.arangodb.conf.graph.name = graph
  gremlin.arangodb.conf.graph.vertex = nodes
  gremlin.arangodb.conf.graph.edge = relationship
  gremlin.arangodb.conf.graph.relation = relationship:nodes->nodes
  gremlin.arangodb.conf.arangodb.hosts = 127.0.0.1:8529
  gremlin.arangodb.conf.arangodb.user = root
  gremlin.arangodb.conf.arangodb.password = xxxxxx

I am asking how to import data, as i saw that when creating collections and populating them through arangodb-thinkerpop, it split properties from vertex and edge collections in different collections: Tinkerpop_ELEMENT-HAS-PROPERTIES and Tinkerpop_ELEMENT-PROPERTIES. So I assume that when we import the data arangodb-thinkerpop will represent them as mentione up.

Thanks in advance.

arcanefoam commented 2 years ago

Hi, The initial design of the tinkerpop driver was not intended to work with existing databases, so atm it is impossible to "import" your data. If you want more information on why this is the case a proposed solution take a look at #38. The headline is that in the Tinkerpop API properties are stored as nodes and the initial implementation replicated this behaviour, making it incompatible with existing databases.

Work on implementing that feature is stalled as I find my self with little free time to work on it. Sponsorship can help allocate time for working on this and I am open to PRs too.