The query of g.V().hasId("customid") does return the vertex, but we are not able to get the properties of the vertex. What is the way to get the vertex with all the properties associated with it..
Traditionally you would use the valueMap step to get the properties and optionally the id and label of the vertex.
g.V().hasId('customid').valueMap();
will return all of the properties of that vertex.
g.V().hasId('customid').valueMap(true);
will also return the ID and the label.
In recent versions of TinkerPop (and DS Graph), there is a cleaner alternative to valueMap called elementMap.
g.V().hasId('customid').elementMap();
and this is essentially equivalent to
g.V().hasId('customid').valueMap(true).by(unfold());
As a recommendation, I would always specify the vertex label with DataStax Graph because it allows the engine to know what vertex/table to start in. So I would do something like:
g.V().hasLabel('order').has('orderid', 1001).elementMap();
or more succinctly
g.V().has('order', 'orderid', 1001).elementMap();
See also
https://tinkerpop.apache.org/docs/current/reference/#elementmap-step
https://tinkerpop.apache.org/docs/current/reference/#valuemap-step
http://www.kelvinlawrence.net/book/PracticalGremlin.html#element-map
http://www.kelvinlawrence.net/book/PracticalGremlin.html#vm
7 People are following this question.
What is the syntax for the "greater than" operator on Date types in Gremlin?
Why is groupCount() returning inconsistent results for vertices?
Is there a limit to adding multiple vertices and edges in a single graph traversal?
Is there a more efficient way to prune cycles without simplePath() ?
What tool can I use to check the underlying Cassandra query fired by a gremlin traversal?
DataStax Enterprise is powered by the best distribution of Apache Cassandra ™
© 2023 DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.
Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.
Privacy Policy Terms of Use