|
| 1 | +# Neo4j-json |
| 2 | +This is the core of `doc2graph` project. |
| 3 | + |
| 4 | +Neo4j-json is a neo4j [plugin](http://neo4j.com/docs/developer-manual/current/extending-neo4j/procedures/), writed for version 3.0 or later, that exposes these procedures: |
| 5 | +* `json.upsert({key},{json})` |
| 6 | +* `json.delete({key})` |
| 7 | + |
| 8 | +These procedures can be called from cypher query and are indipendent from the source of json. |
| 9 | + |
| 10 | +# Neo4j-json install |
| 11 | +To build the default configuration you have to download source and run |
| 12 | + |
| 13 | +``` |
| 14 | +mvn package |
| 15 | +cp target/neo4j-json\*.jar ${NEO_HOME}/plugins/ |
| 16 | +${NEO_HOME}/bin/neo4j restart |
| 17 | +``` |
| 18 | + |
| 19 | +# Neo4j-json configuration |
| 20 | +Neo4j-json is released with a default configuration, but it can be changed by creating a special node. The default configuration is like this: |
| 21 | + |
| 22 | +``` |
| 23 | +CREATE (n:JSON_CONFIG { |
| 24 | + configuration: 'byNode' |
| 25 | + ,root_node_key_property:'_document_key' |
| 26 | + ,document_default_label:'DocNode' |
| 27 | + ,document_id_builder:'org.neo4j.helpers.json.document.impl.DocumentIdBuilderTypeId' |
| 28 | + ,document_relation_builder:'org.neo4j.helpers.json.document.impl.DocumentRelationBuilderTypeArrayKey' |
| 29 | + ,document_label_builder:'org.neo4j.helpers.json.document.impl.DocumentLabelBuilderConstant' |
| 30 | + }) |
| 31 | +``` |
| 32 | + |
| 33 | +If there isn't a JSON\_CONFIG node in database, default configuration is used but no configuration node is created. |
| 34 | + |
| 35 | +**IMPORTANT**: when you change the configuration you must restart the neo4j server. |
| 36 | + |
| 37 | +## configuration |
| 38 | +Node configuration is active only if contains `"configuration: 'byNode'"` else the node is ignored. |
| 39 | + |
| 40 | +## root\_node\_key\_property |
| 41 | +When insert a new document a new root node is created. Upsert procedure set a property with `root_node_key_property` as key and the document key as value. |
| 42 | + |
| 43 | +## document\_default\_label |
| 44 | +All the nodes are created with a label. This is the default label value used by `document_label_builder` if no other label can be applied. |
| 45 | + |
| 46 | +## document\_id\_builder |
| 47 | +It's the name of class that implements `org.neo4j.helpers.json.document.DocumentIdBuilder` interface. It builds a `org.neo4j.helpers.json.document.DocumentId` that stands for primary key value of the sub-document (node). This id is used to seek node in database if already exists. So, it's essential for node reusing. |
| 48 | + |
| 49 | +You can choose from: |
| 50 | +* `org.neo4j.helpers.json.document.impl.DocumentIdBuilderTypeId` |
| 51 | +* `org.neo4j.helpers.json.document.impl.DocumentIdBuilderId` |
| 52 | +* your own implementation |
| 53 | + |
| 54 | + |
| 55 | +**IMPORTANT**: seeking node use also the label so you have to pay attention for label-id combo. |
| 56 | + |
| 57 | +## document\_relation\_builder |
| 58 | +It's the name of class that implements `org.neo4j.helpers.json.document.DocumentRelationBuilder` interface. It manages the relationships, adding and removing them between nodes and deciding which nodes are orphans. Orphan nodes are deleted from database. |
| 59 | + |
| 60 | +You can choose from: |
| 61 | +* `org.neo4j.helpers.json.document.impl.DocumentRelationBuilderTypeArrayKey` |
| 62 | +* `org.neo4j.helpers.json.document.impl.DocumentRelationBuilderByKey` |
| 63 | +* your own implementation |
| 64 | + |
| 65 | +## document\_label\_builder |
| 66 | +It's the name of class that implements `org.neo4j.helpers.json.document.DocumentLabelBuilder` interface. It builds the label that is applied on a node. When it cannot builds from subdocument data it uses the default value (`document_default_label`). Labels are used also to seek node that already exists in database, so you have to use it carefully. |
| 67 | + |
| 68 | +You can choose from: |
| 69 | +* `org.neo4j.helpers.json.document.impl.DocumentLabelBuilderConstant` |
| 70 | +* `org.neo4j.helpers.json.document.impl.DocumentLabelBuilderById` |
| 71 | +* your own implementation |
| 72 | + |
| 73 | +# Performance |
| 74 | +TODO |
| 75 | + |
| 76 | +## License |
| 77 | + |
| 78 | +Copyright (c) 2016 [LARUS Business Automation](http://www.larus-ba.it) |
| 79 | + |
| 80 | +This file is part of the "LARUS Integration Framework for Neo4j". |
| 81 | + |
| 82 | +The "LARUS Integration Framework for Neo4j" is licensed |
| 83 | +under the Apache License, Version 2.0 (the "License"); |
| 84 | +you may not use this file except in compliance with the License. |
| 85 | +You may obtain a copy of the License at |
| 86 | + |
| 87 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 88 | + |
| 89 | +Unless required by applicable law or agreed to in writing, software |
| 90 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 91 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 92 | +See the License for the specific language governing permissions and |
| 93 | +limitations under the License. |
| 94 | + |
0 commit comments