1
TinkerPop有关Neo4j的暗号询问我有一个Neo4j的图(创建使用精怪),我想它使用精怪以及使用,然而,似乎暗号查询图表上不工作:不工作
import org.apache.tinkerpop.gremlin
import gremlin.neo4j.structure.Neo4jGraph
import gremlin.tinkergraph.structure.TinkerGraph
import gremlin.hadoop.structure.HadoopGraph
import org.apache.commons.configuration.Configuration
trait Graph[G] {
def create(location: String, args: Configuration = null): G
}
object Grapher {
implicit val createNeo4j = new Graph[Neo4jGraph] {
def create(location: String, args: Configuration = null) =
if (args != null) Neo4jGraph.open(args) else Neo4jGraph.open(location)
}
implicit val createTinkerGraph = new Graph[TinkerGraph] {
def create(location: String, args: Configuration = null) =
if (args != null) TinkerGraph.open(args) else TinkerGraph.open()
}
implicit val createHadoopGraph = new Graph[HadoopGraph] {
def create(location: String, args: Configuration = null) =
if (args != null) HadoopGraph.open(args) else HadoopGraph.open(location)
}
}
object GraphSyntax {
def createGraph[G](location: String, args: Configuration = null)(implicit graph: Graph[G]) = graph.create(location, args)
}
这是我尝试执行查询:如果我加载图形转换的Neo4j服务器,同样的查询工作的Neo4j的Web控制台上
import Grapher._
import GraphSyntax._
val graph = createGraph[Neo4jGraph](fileName)
// org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph = neo4jgraph[community single [/media/ixaxaar/Source/src/telperion/core/neo4j.db]]
graph.cypher("match (n) return n limit 10").toList
// java.util.List[Nothing] = []
。
match (n) return n limit 10
我使用下列库:
final val Gremlin = "3.2.1"
final val Neo4jTinkerpop = "0.4-3.0.3"
val gremlinCore = "org.apache.tinkerpop" % "gremlin-core" % Version.Gremlin
val gremlinGiraph = "org.apache.tinkerpop" % "giraph-gremlin" % Version.Gremlin
val gremlinNeo4j = "org.apache.tinkerpop" % "neo4j-gremlin" % Version.Gremlin
val hadoopGremlin = "org.apache.tinkerpop" % "hadoop-gremlin" % Version.Gremlin
val tinkergraphGremlin = "org.apache.tinkerpop" % "tinkergraph-gremlin" % Version.Gremlin
val neo4jTinkerpop = "org.neo4j" % "neo4j-tinkerpop-api-impl" % Version.Neo4jTinkerpop
你如何去Gremlin查询Neo?你可以推荐任何Tuts或图书馆? – swelet
如果您已经有一个neo图形,例如在'val location =“〜/ bin/neo4j-community-3.0.4/data/databases/graph.db”中,你可以使用'Neo4jGraph.open(location)'直接将它加载到gremlin中,打开一个遍历val t = graph.traversal()'然后执行gremlin查询val res = tV()。blah()。blah()' 阅读gremlin遍历查询 - > http://tinkerpop.apache.org/ docs/current/reference /#遍历 – ixaxaar
另外,你可以使用'graph.cypher(“匹配你的密码查询”)在gremlin中使用密码'' 如果你需要一些样板,请参考上面的代码(在scala中)。 上面列出了sbt依赖项以及 – ixaxaar