2

I'm successfully using the Neo4J Java API (currently version 2.2.1) to do simple queries like this:

Label label = DynamicLabel.label("User");
ResourceIterator<Node> providers = graphDb.findNodes(
        label, "username", "player1"));

But is there a way to allow something other than a simple match (String in my case) for the values? Can I do REGEX, or provide a list of possible values that the key could match on for string comparisons? If so, are there any examples out there?

I've dug around the docs and my favorite search engines and can't seem to find anything other than a straight string match (such as this: http://neo4j.com/docs/2.2.1/tutorials-java-embedded-new-index.html).

4

2 に答える 2

1

この種のクエリを実行するために、java の内部からサイファー クエリを実行したい場合があることがすぐにわかるでしょう。

String query = "MATCH (n:Label) where n.username =~ ".*foo regex.*" RETURN n;";
try ( Transaction ignored = db.beginTx();
      Result result = db.execute(query) )
{
    while ( result.hasNext() )
    {
         // Do nifty stuff with results.
    }
}

あなたが使用している通常の埋め込み API メソッドは、正規表現やその他の多くのものをサポートするつもりはありません。非常に単純なケース (「プロパティと値でノードを取得する」など) を除いて、cypher を使用することをお勧めします。

于 2015-04-22T21:17:49.170 に答える