2017-08-05 16 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

谢谢!现在我明白了 –