Package com.norconex.committer.neo4j

# Class Neo4jCommitter

java.lang.Object
com.norconex.committer.core3.AbstractCommitter
com.norconex.committer.core3.batch.AbstractBatchCommitter
com.norconex.committer.neo4j.Neo4jCommitter

All Implemented Interfaces:
  `IBatchConsumer`, `ICommitter`, `IXMLConfigurable`, `AutoCloseable`

public class Neo4jCommitter extends AbstractBatchCommitter

Commit documents/fields to a Neo4j graph database.

## Authentication

Basic authentication is supported for password-protected Solr installations.

## XML configuration usage:

    <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>

           </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>

         </committ
        -->

#### XML usage example:

    <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.

Author:
  Sylvain Roussy, Pascal Essiembre

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Neo4jCommitter()`
  Creates a new Neo4j committer with default configuration.
  `Neo4jCommitter(Neo4jCommitterConfig config)`
  Creates a new Neo4j committer with the given configuration.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `closeBatchCommitter()`
  `protected void`
  `commitBatch(Iterator<ICommitterRequest> it)`
  `boolean`
  `equals(Object other)`
  `Neo4jCommitterConfig`
  `getConfig()`
  Gets this committer's configuration.
  `int`
  `hashCode()`
  `protected void`
  `initBatchCommitter()`
  `protected void`
  `loadBatchCommitterFromXML(XML xml)`
  `protected void`
  `saveBatchCommitterToXML(XML xml)`
  `String`
  `toString()`

  ### Methods inherited from class com.norconex.committer.core3.batch.AbstractBatchCommitter

  `consume, doClean, doClose, doDelete, doInit, doUpsert, getCommitterQueue, loadCommitterFromXML, saveCommitterToXML, setCommitterQueue`

  ### Methods inherited from class com.norconex.committer.core3.AbstractCommitter

  `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`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface com.norconex.commons.lang.xml.IXMLConfigurable

  `loadFromXML, saveToXML`

- ## Constructor Details

  - ### Neo4jCommitter

    public Neo4jCommitter()
    Creates a new Neo4j committer with default configuration.

  - ### Neo4jCommitter

    public Neo4jCommitter(Neo4jCommitterConfig config)
    Creates a new Neo4j committer with the given configuration.
    Parameters:
      `config` - committer configuration

- ## Method Details

  - ### initBatchCommitter

    protected void initBatchCommitter() throws CommitterException
    Overrides:
      `initBatchCommitter` in class `AbstractBatchCommitter`
    Throws:
      `CommitterException`

  - ### commitBatch

    protected void commitBatch(Iterator<ICommitterRequest> it) throws CommitterException
    Specified by:
      `commitBatch` in class `AbstractBatchCommitter`
    Throws:
      `CommitterException`

  - ### closeBatchCommitter

    protected void closeBatchCommitter() throws CommitterException
    Overrides:
      `closeBatchCommitter` in class `AbstractBatchCommitter`
    Throws:
      `CommitterException`

  - ### getConfig

    public Neo4jCommitterConfig getConfig()
    Gets this committer's configuration.
    Returns:
      committer configuration

  - ### loadBatchCommitterFromXML

    protected void loadBatchCommitterFromXML(XML xml)
    Specified by:
      `loadBatchCommitterFromXML` in class `AbstractBatchCommitter`

  - ### saveBatchCommitterToXML

    protected void saveBatchCommitterToXML(XML xml)
    Specified by:
      `saveBatchCommitterToXML` in class `AbstractBatchCommitter`

  - ### equals

    public boolean equals(Object other)
    Overrides:
      `equals` in class `AbstractBatchCommitter`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `AbstractBatchCommitter`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `AbstractBatchCommitter`