2017-08-05 67 views
0

Neo4j的版本:3.2.2getDegree()/ isOutgoing()funcitons不graphAware工作/ Neo4j的對elasticsearch mapping.json

操作系統:Ubuntu的16.04

我用getDegree()功能mapping.json文件,但返回將始終爲null;我正在使用數據集neo4j tutorial Movie/Actor數據集。

Output from elasticsearch request

mapping.json

{ 
    "defaults": { 
    "key_property": "uuid", 
    "nodes_index": "default-index-node", 
    "relationships_index": "default-index-relationship", 
    "include_remaining_properties": true 
    }, 
    "node_mappings": [ 
    { 
     "condition": "hasLabel('Person')", 
     "type": "getLabels()", 
     "properties": { 
     "getDegree": "getDegree()", 
     "getDegree(type)": "getDegree('ACTED_IN')", 
     "getDegree(direction)": "getGegree('OUTGOING')", 
     "getDegree('type', 'direction')": "getDegree('ACTED_IN', 'OUTGOING')", 
     "getDegree-degree": "degree" 
     } 
    } 
    ], 
    "relationship_mappings": [ 
    { 
     "condition": "allRelationships()", 
     "type": "type", 
    } 
    ] 
} 

另外,如果我在relationship_mappings屬性部分使用isOutgoing(), isIncoming(), otherNode功能,elasticsearch絕不會從Neo4j的加載關係的數據。我想我大概有這句話only when one of the participating nodes "looking" at the relationship is provided的一些誤解,這個頁面https://github.com/graphaware/neo4j-framework/tree/master/common#inclusion-policies上

mapping.json

{ 
    "defaults": { 
    "key_property": "uuid", 
    "nodes_index": "default-index-node", 
    "relationships_index": "default-index-relationship", 
    "include_remaining_properties": true 
    }, 
    "node_mappings": [ 
    { 
     "condition": "allNodes()", 
     "type": "getLabels()" 
    } 
    ], 
    "relationship_mappings": [ 
    { 
     "condition": "allRelationships()", 
     "type": "type", 
     "properties": { 
     "isOutgoing": "isOutgoing()", 
     "isIncomming": "isIncomming()", 
     "otherNode": "otherNode" 
     } 
    } 
    ] 
} 

BTW,有沒有列出所有我們能在mapping.json使用功能的任何頁面?我知道他們兩個

  1. github.com/graphaware/neo4j-framework/tree/master/common#inclusion-policies
  2. github.com/graphaware/neo4j-to-elasticsearch/blob/master/docs/json-mapper.md 似乎還有更多的,因爲我可以用getType(),這已經不是上述任何網頁已經上市。

請讓我知道如果我能提供任何進一步的幫助來解決問題

謝謝!

回答

1

getDegree()功能不可用,在違背getType()。我將解釋爲什麼:

當映射器(負責創建節點或關係表示的部分作爲ES文檔)正在完成其工作時,它將收到作爲分離節點或關係的DetachedGraphObject

detached的意思是,這是發生在一個事務之外,因此查詢操作都無法對數據庫了。該getType()可用,因爲它是關係元數據的一部分,它是便宜的,但是如果我們想根據人數做同樣的getDegree()這可能是DetachedObject創建(這發生在德克薩斯州)期間,嚴重更昂貴不同類型的等

但是,這是我們正在努力,在加上像KAFA,兔,經紀人一個獨立的Java應用程序外部化映射東西.. n​​eo和這個應用程序之間。但是,我們不會提供在當前版本的模塊中重新查詢圖表的可能性,因爲如果用戶不是非常小心,它可能會有嚴重的性能影響。

截至去年,我可以給你的唯一建議是保持一個屬性與度,你需要複製到ES更新您的節點上。

UPDATE

關於文檔的這一部分:

對於關係,只有當被設置在關係中的參與節點「看」的一個:

這僅使用時不使用json定義,所以你可以使用其中一個。 json定義後來被添加爲add,並且兩者不能一起使用。

對於回答這部分,這意味着輸入或輸出端的節點(取決於定義)應包含在節點的包含策略中,如hasLabel('Employee') || hasProperty('form') || getProperty('age', 0) > 20。如果你有一個allNodes政策,那麼它很好。

+0

謝謝你的詳細解答,Christophe!還有一個問題,只有當一個參與節點「在提供關係時才提供」,意思是在https://github.com/graphaware/neo4j-framework/tree/master/common#inclusion-policies中是什麼意思?我想用isIncoming()/ isOutgoing()函數關係,我該如何提供'看着「關係的節點」 –

+0

我更新了答案 –

+0

謝謝!現在我明白了 –