Spring data neo4j and query with IN keyword

Guillaume

I have many different nodes connected with relationships. On those relationships, I use some properties of type Enum, and I am trying to query through the relationships using the Cyper language and only return those who have the Enum property being in an array. Also, the relationship I am trying to query against is a subclass of another one which has the property I want to query with. Here's an example:

@RelationshipEntity
public class Mother {

    @Indexed(level=Level.INSTANCE) Visibility visibility;
    public Visibility getVisibility() {
        return visibility;
    }
    public void setVisibility(Visibility visibility) {
        this.visibility = visibility;
    }
}

public class Child extends Mother {
    @StartNode StartNode start;
    @EndNode EndNode end;
}

Imagine that the visibility is an enum that can be either Private, Network or Public. Then in a repository I tried the following queries, but it always returns everything or throws an error:

@Query("start s=node({0}) match s-[r:TYPE]->e where r.visibility='Private' return r")
Iterable<Child> findChildren(StartNode start);
@Query("start s=node({0}) match s-[r:TYPE]->e where r.visibility=\"Private\" return r")
Iterable<Child> findChildren(StartNode start);
@Query("start s=node({0}) match s-[r:TYPE]->e where r.visibility=Private return r")
Iterable<Child> findChildren(StartNode start);

What I would really like to use is the 'IN' operator, but that throws an error like if it didn't know what IN was.

@Query("start s=node({0}) match s-[r:TYPE]->e where r.visibility in ['Private', 'Network'] return r")
Iterable<Child> findChildren(StartNode start);

Is my Visibility not being indexed? or am I not supposed to do this? I haven't tried changing the Visibility property by a string instead, which I suppose should work since I have other String properties that I can query against successfully. Using the 'IN' operator is a bonus!

Edit 1: I am using spring-data-neo4j 2.0.1.RELEASE. I am trying to do this in Unit testing, using org.neo4j.test.ImpermanentGraphDatabase, but I just realised that the query @Query("start s=node({0}) match s-[r:TYPE]->e where r.visibility='Private' return r") works when running the server, using the default configuration, but it still doesn't work in unit testing. Also, even when running the server, the 'IN' clause still throws an error. Is this related to the version I am using? I remember trying to use a more recent version but then dependencies failed, maybe I should try again.

Edit 2: So I updated the version of spring-data-neo4j to 2.1.0.BUILD-SNAPSHOT, upgraded neo4j version to 1.7 also. Now I don't have an error for the 'IN' keyword, but I don't know what syntax should I use to pass along the values to search against. So having

@Query("start s=node({0}) match s-[r:TYPE]->e where r.visibility in [{1}] return r")
Iterable<Child> findChildren(StartNode start, String visibility);

works if I pass along a simple String like Public, but not if I pass along Public, Private which never returns anything, even though Public does return matches. I also tried changing the parameter String visibility for a String[] visibility, but that doesn't work at all.

lassewesth

@Guillaume,

This is done: https://jira.springsource.org/browse/DATAGRAPH-281

It is available in build snapshots, and will be in SDN 2.1.RC4/GA

Regards,

Lasse

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Neo4j TimeTree in Spring Data Neo4j 4.0

分類Dev

Cannot configure @Transaction to work with Spring Data Neo4j

分類Dev

Spring Data Neo4j / OGM-java.lang.NoSuchMethodError:org.neo4j.ogm.session.Session.load

分類Dev

Spring Data Neo4j 4 と動的プロパティ

分類Dev

Enabling two Spring Data repositories (neo4j and h2) in the same application context

分類Dev

Enabling two Spring Data repositories (neo4j and h2) in the same application context

分類Dev

Enabling two Spring Data repositories (neo4j and h2) in the same application context

分類Dev

Spring Data Neo4j 4.2.0.BUILD-SNAPSHOT OGM 2.1.0-SNAPSHOT NullPointerException

分類Dev

Spring Data Neo4j 4とneo4j-ogmの違いは何ですか?

分類Dev

neo4j query execution

分類Dev

Improve Neo4j query performance

分類Dev

Spring Data Neo4j 4でのページングとソート

分類Dev

Spring Data Neo4j 4、OGM および @Relationship アノテーション

分類Dev

Neo4jでの双方向関係の命名規則(Spring Dataを使用)

分類Dev

Spring Data Neo4JリポジトリのfindAll()はnullpointerexceptionになります

分類Dev

Spring Data Neo4j:複雑な関係が持続しない

分類Dev

Spring Data Neo4j neo4jTemplate.fetch()は1つの値のみを返します

分類Dev

Neo4j Adding multiple CSV in one query

分類Dev

Neo4J Cypher query equivalent to select for update

分類Dev

neo4j cypher : how to query a linked list

分類Dev

Query Node from Neo4j by using java

分類Dev

neo4j cypher: "stacking" nodes from query result

分類Dev

Neo4j cypher query a known path

分類Dev

spring-data-neo4jを使用してNeo4jのプロパティデータ型を変更します

分類Dev

Spring Data Neo4J 3.3.1を使用してデータベースを作成すると、Neo4j2.2.3サーバーの起動に失敗する

分類Dev

neo4jによるSpring認証

分類Dev

特定のIDでSpring Data Neo4jリポジトリの保存メソッドを使用する方法

分類Dev

リポジトリクエリで列挙型を使用できません(neo4j / Spring Data)

分類Dev

Spring Data Neo4j(SDN):暗号化されていないネストされたオブジェクト

Related 関連記事

  1. 1

    Neo4j TimeTree in Spring Data Neo4j 4.0

  2. 2

    Cannot configure @Transaction to work with Spring Data Neo4j

  3. 3

    Spring Data Neo4j / OGM-java.lang.NoSuchMethodError:org.neo4j.ogm.session.Session.load

  4. 4

    Spring Data Neo4j 4 と動的プロパティ

  5. 5

    Enabling two Spring Data repositories (neo4j and h2) in the same application context

  6. 6

    Enabling two Spring Data repositories (neo4j and h2) in the same application context

  7. 7

    Enabling two Spring Data repositories (neo4j and h2) in the same application context

  8. 8

    Spring Data Neo4j 4.2.0.BUILD-SNAPSHOT OGM 2.1.0-SNAPSHOT NullPointerException

  9. 9

    Spring Data Neo4j 4とneo4j-ogmの違いは何ですか?

  10. 10

    neo4j query execution

  11. 11

    Improve Neo4j query performance

  12. 12

    Spring Data Neo4j 4でのページングとソート

  13. 13

    Spring Data Neo4j 4、OGM および @Relationship アノテーション

  14. 14

    Neo4jでの双方向関係の命名規則(Spring Dataを使用)

  15. 15

    Spring Data Neo4JリポジトリのfindAll()はnullpointerexceptionになります

  16. 16

    Spring Data Neo4j:複雑な関係が持続しない

  17. 17

    Spring Data Neo4j neo4jTemplate.fetch()は1つの値のみを返します

  18. 18

    Neo4j Adding multiple CSV in one query

  19. 19

    Neo4J Cypher query equivalent to select for update

  20. 20

    neo4j cypher : how to query a linked list

  21. 21

    Query Node from Neo4j by using java

  22. 22

    neo4j cypher: "stacking" nodes from query result

  23. 23

    Neo4j cypher query a known path

  24. 24

    spring-data-neo4jを使用してNeo4jのプロパティデータ型を変更します

  25. 25

    Spring Data Neo4J 3.3.1を使用してデータベースを作成すると、Neo4j2.2.3サーバーの起動に失敗する

  26. 26

    neo4jによるSpring認証

  27. 27

    特定のIDでSpring Data Neo4jリポジトリの保存メソッドを使用する方法

  28. 28

    リポジトリクエリで列挙型を使用できません(neo4j / Spring Data)

  29. 29

    Spring Data Neo4j(SDN):暗号化されていないネストされたオブジェクト

ホットタグ

アーカイブ