2013-08-19 2 views
2

속성 순서를 제어하는 ​​메커니즘이 있습니까?Neo4j 속성 순서를 제어 할 수 있습니까?

CREATE (m1 {`$type`: {moduleTypeName}, Name: 'M1', ModelNumber: 'MN1'}) 
다음

나중에 나는 REST 사이퍼 엔드 포인트 I을 사용하여 사이퍼 쿼리에서 다시이 노드를 얻을 : 다음 작업을 수행 할 경우

나는 Neo4j 1.9.2 커뮤니티를 사용 http://www.neo4j.org/console

이를 재현 할 수 없습니다 ... 다시 내가 JSON을 구문 분석 http://james.newtonking.com/pages/json-net.aspx을 사용하고

{ 
    "extensions": {}, 
    "paged_traverse": "http://localhost:7575/db/data/node/3777/paged/traverse/{returnType}{?pageSize,leaseTime}", 
    "outgoing_relationships": "http://localhost:7575/db/data/node/3777/relationships/out", 
    "traverse": "http://localhost:7575/db/data/node/3777/traverse/{returnType}", 
    "all_typed_relationships": "http://localhost:7575/db/data/node/3777/relationships/all/{-list|&|types}", 
    "property": "http://localhost:7575/db/data/node/3777/properties/{key}", 
    "all_relationships": "http://localhost:7575/db/data/node/3777/relationships/all", 
    "self": "http://localhost:7575/db/data/node/3777", 
    "properties": "http://localhost:7575/db/data/node/3777/properties", 
    "outgoing_typed_relationships": "http://localhost:7575/db/data/node/3777/relationships/out/{-list|&|types}", 
    "incoming_relationships": "http://localhost:7575/db/data/node/3777/relationships/in", 
    "incoming_typed_relationships": "http://localhost:7575/db/data/node/3777/relationships/in/{-list|&|types}", 
    "create_relationship": "http://localhost:7575/db/data/node/3777/relationships", 
    "data": { 
     "ModelNumber": "MN1", 
     "$type": "ModuleType", 
     "Name": "M1" 
    } 
} 

을 얻을하고 자동으로 개체 유형을 추론를 들어, $ 유형 속성을 먼저해야합니다 . 스트림에서 JSON을 구문 분석 할 때 먼저 전체 내용을 메모리에로드하지 않으려 고 할 때 유용합니다.

알파벳순으로 표시되지 않으며 임의적으로 보이지 않습니다. 순서가 다른 객체 유형에 대해 일관성이 있지만 일관성이없는 것 같습니다.

셸에서도 노드를 가져 왔으므로 순서가 노드를 얻는 방법에 의존하지 않지만 노드를 만드는 순서와 관련이없는 것처럼 보입니다.

답변

3

속성에는 보증 된 순서가 없습니다. '어쩌면'주문에 대한 어떠한 가정도하지 마십시오. 다가오는 버전이이 가정 된 동작을 변경하고 코드를 위반할 수 있습니다.

Cypher에서 노드 자체를 반환하지 않는 것이 속성 목록 (예 :

START node=node(<myid>) 
RETURN node.`$type`, node.ModelNumber, node.Name 

여기에는 정의 된 열이 있습니다.

+0

불행히도 cypher는 POJO/POCO 매핑을 약간 더 미묘하게 만드는 {columns : [], data : []} 정렬 방식으로 속성을 반환합니다. – LameCoder

+0

json 응답의 데이터 부분 만 사용한다면 괜찮을 것입니다. –

관련 문제