0

Short

I can't get neo to update existing node properties in a batched rest op.

Long

I want to create a batch operation that inserts/updates a node inside an index. It should handle three use-cases:

  1. if the node does not exist, insert it with the given properties set
  2. if the node exists, update it's properties set with the new values, if any.

I'm using the batch operation api, I wrote a test where I'm issuing two requests: Short 1. first one inserts the node and indexes it's properties 2. second one simply updates some properties of the node

Here's the first request:

[ { "method": "POST", "to": "/index/node/events?uniqueness=get_or_create", "id": 1, "body": { "key": "id", "value": "222222222", "properties": { "id": "222222222", "type": "event-type" } } }, { "method": "POST", "to": "/index/node/events", "body": { "uri": "{1}", "key": "id", "value": "222222222" } }, { "method": "POST", "to": "/index/node/events", "body": { "uri": "{1}", "key": "type", "value": "event-type" } } ]

And now the second one.

[ { method: 'POST', to: '/index/node/events?uniqueness=get_or_create', id: 1, body: { key: 'id', value: '222222222', properties: {id: '222222222', type: 'event-type', title: 'SUPEREVENT'} } }, { method: 'POST', to: '/index/node/events', body: { uri: '{1}', key: 'id', value: '222222222' } }, { method: 'POST', to: '/index/node/events', body: { uri: '{1}', key: 'type', value: 'event-type' } }, { method: 'POST', to: '/index/node/events', body: { uri: '{ 1 }', key: 'title', value: 'SUPEREVENT' } } ]

NOTE! that on the second request i'm adding and event title property with value SUPEREVENT. This does not get persisted nor indexed. Why? and how can I fix it?

Thank you, Alex

4

1 回答 1

0

从文档:

URL 参数唯一性=get_or_create:创建一个新的节点/关系,如果找不到现有的,则对其进行索引。如果找到现有节点/关系,则丢弃发送的数据并返回现有节点/关系。

因此,您的第二个请求的数据将被丢弃。您需要将每个请求分成两个请求,并分两批进行。两个批次中的每一个都有两个指令:第一个如果不存在则创建节点,第二个更新属性。

于 2013-10-25T07:18:22.030 回答