public class Neo4jCommitter extends AbstractBatchCommitter
Commit documents/fields to a Neo4j graph database.
Basic authentication is supported for password-protected Solr installations.
Passwords can be encrypted using EncryptionUtil
(or
command-line "encrypt.bat" or "encrypt.sh" if those are available to you).
In order for the password to be decrypted properly, you need
to specify the encryption key used to encrypt it. The key can obtained
from a few supported locations. The combination of the password key
"value" and "source" is used to properly locate the key.
The supported sources are:
key |
The actual encryption key. |
file |
Path to a file containing the encryption key. |
environment |
Name of an environment variable containing the key. |
property |
Name of a JVM system property containing the key. |
Optionally apply a committer only to certain type of documents. Documents are restricted based on their metadata field names and values. This option can be used to perform document routing when you have multiple committers defined.
By default, this abstract class applies field mappings for metadata fields, but leaves the document reference and content (input stream) for concrete implementations to handle. In other words, they only apply to a committer request metadata. Field mappings are performed on committer requests before upserts and deletes are actually performed.
<committer
class="com.norconex.committer.neo4j.Neo4jCommitter">
<!--
Mandatory settings --->
<uri>
(Required connection URI. E.g., "bolt://localhost:7687".)
</uri>
<upsertCypher>
(Cypher query for adding relationships to Neo4j. Typically,
you want to use MERGE and the "nodeIdProperty" value to update
existing entries matching the ID. In order to delete all nodes
related to an entry, make sure to add the ID property on all
appropriate nodes.
The query parameters correspond the document fields.)
</upsertCypher>
<deleteCypher>
(Cypher query for adding relationships to Neo4j. Typically,
you want to use "nodeIdProperty" value to delete nodes having
a matching property value. The query parameters correspond the
document fields.)
</deleteCypher>
<!-- Optional settings --->
<database>
(A database name when using one other than the default one.)
</database>
<credentials>
<username>(the username)</username>
<password>(the optionally encrypted password)</password>
<passwordKey>
<value>(The actual password encryption key or a reference to it.)</value>
<source>[key|file|environment|property]</source>
<size>(Size in bits of encryption key. Default is 128.)</size>
</passwordKey>
</credentials>
<multiValuesJoiner>
(One or more characters to join multi-value fields. Default is "|".)
</multiValuesJoiner>
<nodeIdProperty>
(Optional property name where to store the document reference
in Neo4j graph entries. Use it as a cypher parameter to uniquely
identify your graph entries in your configured "upsertCypher" and
"deleteCypher" queries. Default is "id".)
</nodeIdProperty>
<nodeContentProperty>
(Optional property name where to store the document content
in Neo4j graph entries. Use it as a cypher parameter
in your configured "upsertCypher" query. Default is "content".)
</nodeContentProperty>
<optionalParameters>
(Comma-separated list of parameter names that can be missing when
creating the query. They will be set to {@link NullValue}) to avoid
client exception for missing parameters.)
<optionalParameters>
<!-- multiple "restrictTo" tags allowed (only one needs to match)
-->
<restrictTo>
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(field-matching expression)
</fieldMatcher>
<valueMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(value-matching expression)
</valueMatcher>
</restrictTo>
<fieldMappings>
<!-- Add as many field mappings as needed -->
<mapping
fromField="(source field name)"
toField="(target field name)"/>
</fieldMappings>
<!-- Settings for default queue implementation ("class" is optional): -->
<queue
class="com.norconex.committer.core3.batch.queue.impl.FSQueue">
<batchSize>
(Optional number of documents queued after which we process a batch.
Default is 20.)
</batchSize>
<maxPerFolder>
(Optional maximum number of files or directories that can be queued
in a single folder before a new one gets created. Default is 500.)
</maxPerFolder>
<commitLeftoversOnInit>
(Optionally force to commit any leftover documents from a previous
execution. E.g., prematurely ended. Default is "false").
</commitLeftoversOnInit>
<onCommitFailure>
<splitBatch>[OFF|HALF|ONE]</splitBatch>
<maxRetries>(Max retries upon commit failures. Default is 0.)</maxRetries>
<retryDelay>
(Delay in milliseconds between retries. Default is 0.)
</retryDelay>
<ignoreErrors>
[false|true]
(When true, non-critical exceptions when interacting with the target
repository won't be thrown to try continue the execution with other
files to be committed. Instead, errors will be logged.
In both cases the failing batch/files are moved to an
"error" folder. Other types of exceptions may still be thrown.)
</ignoreErrors>
</onCommitFailure>
</queue>
</committer>
<committer
class="com.norconex.committer.neo4j.Neo4jCommitter">
<uri>bolt://localhost:7687</uri>
<upsertCypher>
MERGE (a:Document { docId: $id })
SET a += { title: $title }
SET a += { author: $author }
</upsertCypher>
<deleteCypher>
MATCH (a:Document { docId: $id })
DETACH DELETE a
</deleteCypher>
<credentials>
<username>neo4j</username>
<password>AcwFJPHITfk6LrRp7HW7Ag6hvDZotXcvWt2WvDMcGIo=</password>
<passwordKey>
<value>key.txt</value>
<source>file</source>
</passwordKey>
</credentials>
<multiValuesJoiner>_</multiValuesJoiner>
</committer>
The above example creates a graph of collected documents.
Constructor and Description |
---|
Neo4jCommitter() |
Neo4jCommitter(Neo4jCommitterConfig config) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeBatchCommitter() |
protected void |
commitBatch(Iterator<ICommitterRequest> it) |
boolean |
equals(Object other) |
Neo4jCommitterConfig |
getConfig() |
int |
hashCode() |
protected void |
initBatchCommitter() |
protected void |
loadBatchCommitterFromXML(XML xml) |
protected void |
saveBatchCommitterToXML(XML xml) |
String |
toString() |
consume, doClean, doClose, doDelete, doInit, doUpsert, getCommitterQueue, loadCommitterFromXML, saveCommitterToXML, setCommitterQueue
accept, addRestriction, addRestrictions, applyFieldMappings, clean, clearFieldMappings, clearRestrictions, close, delete, fireDebug, fireDebug, fireError, fireError, fireInfo, fireInfo, getCommitterContext, getFieldMappings, getRestrictions, init, loadFromXML, removeFieldMapping, removeRestriction, removeRestriction, saveToXML, setFieldMapping, setFieldMappings, upsert
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
loadFromXML, saveToXML
public Neo4jCommitter()
public Neo4jCommitter(Neo4jCommitterConfig config)
protected void initBatchCommitter() throws CommitterException
initBatchCommitter
in class AbstractBatchCommitter
CommitterException
protected void commitBatch(Iterator<ICommitterRequest> it) throws CommitterException
commitBatch
in class AbstractBatchCommitter
CommitterException
protected void closeBatchCommitter() throws CommitterException
closeBatchCommitter
in class AbstractBatchCommitter
CommitterException
public Neo4jCommitterConfig getConfig()
protected void loadBatchCommitterFromXML(XML xml)
loadBatchCommitterFromXML
in class AbstractBatchCommitter
protected void saveBatchCommitterToXML(XML xml)
saveBatchCommitterToXML
in class AbstractBatchCommitter
public boolean equals(Object other)
equals
in class AbstractBatchCommitter
public int hashCode()
hashCode
in class AbstractBatchCommitter
public String toString()
toString
in class AbstractBatchCommitter
Copyright © 2018–2022 Norconex Inc.. All rights reserved.