1
votes

I use Java to connect to a "remote" (localhost:8182) Gremlin server g this way:

traversalSource = traversal().withRemote(DriverRemoteConnection.using("localhost", 8182, "g"));

Then, I write some node like this:

traversalSource.addV("TenantProfile");

From Gremlin console, connected to the same Gremlin server, I see all created nodes and edges

gremlin> g==>graphtraversalsource[tinkergraph[vertices:42 edges:64], standard]

and queries work, but if I read graph from Java, it results empty, so querying e.g. like

traversalSource.V()
                        .has("label", TENANT_PROFILE_LABEL)
                        .has("fiscal id", "04228480408")
                        .out(OWNS_LABEL)
                        .has("type", "SH")
                        .values("description")
                        .toList();

returns an emtpy list.

Could anyone help me solve this mistery, please? Thanks.

1
I forgot to say I invoke iterate() at the end of insertions (triple dots were deleted by editor, I guess)IlMinistro
I'm not sure that to make of this issue. If you have the same graph data and your traversal works in Gremlin Console against that data then I can't think of any reason why you wouldn't get the same result from Java especially if you terminate your traversal with a terminal step like toList(). I think you will have to try to provide a more complete example with some sample data that reproduces this problem.stephen mallette
one think i'm just noticing is that you included this ">graphtraversalsource[tinkergraph[vertices:42 edges:64], standard]" as evidence that your data is present. That's demonstrating a local embedded connection to your graph not a remote one, which means that it's possible you're not really proving that Gremlin Console is getting data from Gremlin Server. Again, you may want to edit your question to include a more complete demonstration of the issue.stephen mallette

1 Answers

0
votes

In reply to Stephen, I post the last instructions before iterate()

for (final Map<String, String> edgePropertyMap : edgePropertyTable) {
            edgeTraversal = traversalSource
                            .V(vertices.get(edgePropertyMap.get(FROM_KEY)))
                            .addE(edgeLabel)
                            .to(vertices.get(edgePropertyMap.get(TO_KEY)));

            final Set<String> edgePropertyNames = edgePropertyMap.keySet();
            for (final String nodePropertyName : edgePropertyNames)
                if ((!nodePropertyName.equals(FROM_KEY)) && (!nodePropertyName.equals(TO_KEY))) {
                    final String edgePropertyValue = edgePropertyMap.get(nodePropertyName);
                    edgeTraversal = edgeTraversal.property(nodePropertyName, edgePropertyValue);
                }

            edgeTraversal.as(edgePropertyMap.get(IDENTIFIER_KEY)).iterate();
        }

Anyway, if no iterate() were present, how could nodes and edges be visible from inside console? How could they have been "finalized" on remote server?