Class AzureSearchCommitter
- All Implemented Interfaces:
BatchConsumer,Committer,Configurable<AzureSearchCommitterConfig>,AutoCloseable
Commits documents to Microsoft Azure Search.
Document reference encoding
By default the document reference (Azure Search Document Key) is
encoded using URL-safe Base64 encoding. This is Azure Search recommended
approach when a document unique id can contain special characters
(e.g. a URL). If you know your document references to be safe
(e.g. a sequence number), you can
set AzureSearchCommitterConfig.setDisableDocKeyEncoding(boolean)
to true.
To otherwise store a reference value un-encoded, you can additionally
store it in a field other than your reference ("id") field.
Single vs multiple values
Fields with single value will be sent as such, while multi-value fields are sent as array. If you have a field defined as an array in Azure Search, sending a single value may cause an error.
It is possible for values to always
be sent as arrays for specific fields. This is done using
AzureSearchCommitterConfig.setArrayFields(String).
It expects comma-separated-value list
or a regular expression, depending of the value you set for
AzureSearchCommitterConfig.setArrayFieldsRegex(boolean).
Field names and errors
Azure Search will produce an error if any of the documents in a submitted
batch contains one or more fields with invalid characters. To prevent
sending those in vain, the committer will validate your fields
and throw an exception upon encountering an invalid one.
To prevent exceptions from being thrown, you can set
AzureSearchCommitterConfig.setIgnoreValidationErrors(boolean)
to true to log those errors instead.
An exception will also be thrown for errors returned by Azure Search
(e.g. a field is not defined in your
Azure Search schema). To also log those errors instead of throwing an
exception, you can set
AzureSearchCommitterConfig.setIgnoreResponseErrors(boolean)
to true.
Field naming rules
Those are the field naming rules mandated for Azure Search (in force for Azure Search version 2016-09-01): Search version
- Document reference (ID): Letters, numbers, dashes ("-"), underscores ("_"), and equal signs ("="). First character cannot be an underscore.
- Document field name: Letters, numbers, underscores ("_"). First character must be a letter. Cannot start with "azureSearch". Maximum length is 128 characters.
- Author:
- Pascal Essiembre
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected voidSubclasses can perform additional closing logic by overriding this method.protected voidCommits the supplied batch.booleaninthashCode()protected voidSubclasses can perform additional initialization by overriding this method.toString()Methods inherited from class com.norconex.committer.core.batch.AbstractBatchCommitter
consume, doClean, doClose, doDelete, doInit, doUpsert, getInitializedQueueMethods inherited from class com.norconex.committer.core.AbstractCommitter
accept, applyFieldMappings, clean, close, delete, fireDebug, fireDebug, fireError, fireError, fireInfo, fireInfo, getCommitterContext, init, upsert
-
Constructor Details
-
AzureSearchCommitter
public AzureSearchCommitter()
-
-
Method Details
-
initBatchCommitter
Description copied from class:AbstractBatchCommitterSubclasses can perform additional initialization by overriding this method. Default implementation does nothing. The committer context and committer queue will be already initialized when invokingAbstractCommitter.getCommitterContext()andAbstractBatchCommitter.getInitializedQueue(), respectively.- Overrides:
initBatchCommitterin classAbstractBatchCommitter<AzureSearchCommitterConfig>- Throws:
CommitterException- error initializing
-
commitBatch
Description copied from class:AbstractBatchCommitterCommits the supplied batch.- Specified by:
commitBatchin classAbstractBatchCommitter<AzureSearchCommitterConfig>- Parameters:
it- the batch to commit- Throws:
CommitterException- could not commit the batch
-
closeBatchCommitter
Description copied from class:AbstractBatchCommitterSubclasses can perform additional closing logic by overriding this method. Default implementation does nothing.- Overrides:
closeBatchCommitterin classAbstractBatchCommitter<AzureSearchCommitterConfig>- Throws:
CommitterException- error closing committer
-
equals
- Overrides:
equalsin classAbstractBatchCommitter<AzureSearchCommitterConfig>
-
canEqual
- Overrides:
canEqualin classAbstractBatchCommitter<AzureSearchCommitterConfig>
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractBatchCommitter<AzureSearchCommitterConfig>
-
toString
- Overrides:
toStringin classAbstractBatchCommitter<AzureSearchCommitterConfig>
-
getConfiguration
-