public class SolrCommitter extends AbstractMappedCommitter
Commits documents to Apache Solr.
As of 2.4.0, it is possible to specify which type of
Solr Client to use.
The expected configuration value of "solrURL" is influenced
by the client type chosen. Default client type is
HttpSolrClient. The clients are:
Since 2.4.0, BASIC authentication is supported for password-protected
Solr installations.
The password can optionally be
encrypted using EncryptionUtil (or command-line "encrypt.bat"
or "encrypt.sh").
In order for the password to be decrypted properly, you need
to specify the encryption key used to encrypt it. The key can be stored
in a few supported locations and a combination of
passwordKey
and passwordKeySource must be specified to properly
locate the key. The supported sources are:
passwordKeySource |
passwordKey |
|---|---|
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. |
As of 2.2.1, XML configuration entries expecting millisecond durations
can be provided in human-readable format (English only), as per
DurationParser (e.g., "5 minutes and 30 seconds" or "5m30s").
<committer class="com.norconex.committer.solr.SolrCommitter">
<solrClientType>
(See class documentation for options. Default: HttpSolrClient.)
</solrClientType>
<solrURL>(URL to Solr)</solrURL>
<solrUpdateURLParams>
<param name="(parameter name)">(parameter value)</param>
<-- multiple param tags allowed -->
</solrUpdateURLParams>
<solrCommitDisabled>[false|true]</solrCommitDisabled>
<!-- Use the following if BASIC authentication is required. -->
<username>(Optional user name)</username>
<password>(Optional user password)</password>
<!-- Use the following if password is encrypted. -->
<passwordKey>(the encryption key or a reference to it)</passwordKey>
<passwordKeySource>[key|file|environment|property]</passwordKeySource>
<sourceReferenceField keep="[false|true]">
(Optional name of field that contains the document reference, when
the default document reference is not used. The reference value
will be mapped to Solr "id" field, or the "targetReferenceField"
specified.
Once re-mapped, this metadata source field is
deleted, unless "keep" is set to true.)
</sourceReferenceField>
<targetReferenceField>
(Name of Solr target field where the store a document unique
identifier (idSourceField). If not specified, default is "id".)
</targetReferenceField>
<sourceContentField keep="[false|true]">
(If you wish to use a metadata field to act as the document
"content", you can specify that field here. Default
does not take a metadata field but rather the document content.
Once re-mapped, the metadata source field is deleted,
unless "keep" is set to true.)
</sourceContentField>
<targetContentField>
(Solr target field name for a document content/body.
Default is: content)
</targetContentField>
<commitBatchSize>
(Maximum number of docs to send Solr at once. Will issue a Solr
commit unless "solrCommitDisabled" is true)
</commitBatchSize>
<queueDir>(optional path where to queue files)</queueDir>
<queueSize>(max queue size before sending to Solr)</queueSize>
<maxRetries>(max retries upon commit failures)</maxRetries>
<maxRetryWait>(max delay in milliseconds between retries)</maxRetryWait>
</committer>
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_SOLR_CONTENT_FIELD
Default Solr content field
|
static String |
DEFAULT_SOLR_ID_FIELD
Default Solr ID field
|
DEFAULT_COMMIT_BATCH_SIZEDEFAULT_QUEUE_DIR, filesCommittingDEFAULT_QUEUE_SIZE, queueSize| Constructor and Description |
|---|
SolrCommitter()
Constructor.
|
SolrCommitter(org.apache.solr.client.solrj.SolrClient solrClient)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
commitBatch(List<ICommitOperation> batch) |
boolean |
equals(Object obj) |
String |
getPassword()
Gets the password.
|
EncryptionKey |
getPasswordKey()
Gets the password encryption key.
|
SolrClientType |
getSolrClientType()
Gets the Solr client type.
|
String |
getSolrURL()
Gets the Solr URL.
|
String |
getUpdateUrlParam(String name)
Gets a URL parameter value by its parameter name.
|
Set<String> |
getUpdateUrlParamNames()
Gets the update URL parameter names.
|
String |
getUsername()
Gets the username.
|
int |
hashCode() |
boolean |
isSolrCommitDisabled()
Gets whether to send an explicit commit request at the end of every
batch, or let the server auto-commit.
|
protected void |
loadFromXml(XMLConfiguration xml) |
protected void |
saveToXML(XMLStreamWriter writer) |
void |
setPassword(String password)
Sets the password.
|
void |
setPasswordKey(EncryptionKey passwordKey)
Sets the password encryption key.
|
void |
setSolrClientType(SolrClientType solrClientType)
Sets the Solr client type.
|
void |
setSolrCommitDisabled(boolean solrCommitDisabled)
Sets whether to send an explicit commit request at the end of every
batch, or let the server auto-commit.
|
void |
setSolrURL(String solrURL)
Sets the Solr URL.
|
void |
setUpdateUrlParam(String name,
String value)
Sets URL parameters to be added on Solr HTTP calls.
|
void |
setUsername(String username)
Sets the username.
|
protected org.apache.solr.client.solrj.request.UpdateRequest |
solrAddRequest(IAddOperation op) |
protected org.apache.solr.client.solrj.request.UpdateRequest |
solrDeleteRequest(IDeleteOperation op) |
String |
toString() |
getSourceContentField, getSourceReferenceField, getTargetContentField, getTargetReferenceField, isKeepSourceContentField, isKeepSourceReferenceField, loadFromXML, prepareCommitAddition, saveToXML, setKeepSourceContentField, setKeepSourceReferenceField, setSourceContentField, setSourceReferenceField, setTargetContentField, setTargetReferenceFieldcommitAddition, commitComplete, commitDeletion, getCommitBatchSize, getMaxRetries, getMaxRetryWait, setCommitBatchSize, setMaxRetries, setMaxRetryWaitcommit, getInitialQueueDocCount, getQueueDir, prepareCommitDeletion, queueAddition, queueRemoval, setQueueDiradd, getQueueSize, remove, setQueueSizepublic static final String DEFAULT_SOLR_ID_FIELD
public static final String DEFAULT_SOLR_CONTENT_FIELD
public SolrCommitter()
public SolrCommitter(org.apache.solr.client.solrj.SolrClient solrClient)
solrClient - SolrClient to usepublic SolrClientType getSolrClientType()
public void setSolrClientType(SolrClientType solrClientType)
solrClientType - solr client typepublic String getSolrURL()
public void setSolrURL(String solrURL)
solrURL - solrURLpublic void setUpdateUrlParam(String name, String value)
name - parameter namevalue - parameter valuepublic String getUpdateUrlParam(String name)
name - parameter namepublic Set<String> getUpdateUrlParamNames()
public void setSolrCommitDisabled(boolean solrCommitDisabled)
solrCommitDisabled - true if sending Solr commit is
disabledpublic boolean isSolrCommitDisabled()
true if sending Solr commit is disabled.public String getUsername()
public void setUsername(String username)
username - the usernamepublic String getPassword()
public void setPassword(String password)
password - the passwordpublic EncryptionKey getPasswordKey()
null if the password is not
encrypted.EncryptionUtilpublic void setPasswordKey(EncryptionKey passwordKey)
passwordKey - password keyEncryptionUtilprotected void commitBatch(List<ICommitOperation> batch)
commitBatch in class AbstractBatchCommitterprotected org.apache.solr.client.solrj.request.UpdateRequest solrAddRequest(IAddOperation op)
protected org.apache.solr.client.solrj.request.UpdateRequest solrDeleteRequest(IDeleteOperation op)
protected void saveToXML(XMLStreamWriter writer) throws XMLStreamException
saveToXML in class AbstractMappedCommitterXMLStreamExceptionprotected void loadFromXml(XMLConfiguration xml)
loadFromXml in class AbstractMappedCommitterpublic int hashCode()
hashCode in class AbstractMappedCommitterpublic boolean equals(Object obj)
equals in class AbstractMappedCommitterpublic String toString()
toString in class AbstractMappedCommitterCopyright © 2009–2021 Norconex Inc.. All rights reserved.