Package de.cxp.ocs.indexer
Class AbstractIndexer
- java.lang.Object
-
- de.cxp.ocs.indexer.AbstractIndexer
-
- All Implemented Interfaces:
FullIndexationService,UpdateIndexService
- Direct Known Subclasses:
ElasticsearchIndexer
public abstract class AbstractIndexer extends Object implements FullIndexationService, UpdateIndexService
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.cxp.ocs.api.indexer.UpdateIndexService
UpdateIndexService.Result
-
-
Constructor Summary
Constructors Constructor Description AbstractIndexer(@NonNull List<DocumentPreProcessor> dataPreProcessors, @NonNull List<DocumentPostProcessor> postProcessors, @NonNull FieldConfigIndex fieldConfIndex)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Document_get(@NonNull String indexName, @NonNull String docId)protected abstract UpdateIndexService.Result_patch(String index, IndexableItem indexableItem)protected abstract UpdateIndexService.Result_put(String indexName, Boolean replaceExisting, IndexableItem indexableItem)intadd(BulkImportData data)Add one or more documents to a running import session.protected abstract intaddToIndex(ImportSession session, List<IndexableItem> bulk)voidcancel(ImportSession session)Cancels import which results in a deletion of the temporary index.protected abstract voiddeleteIndex(String indexName)protected abstract booleandeploy(ImportSession session)booleandone(ImportSession session)Finishes the import, flushing the new index and (in case there is already an index with the initialized name) replacing the old one.protected abstract StringinitNewIndex(String indexName, String locale)abstract booleanisImportRunning(String indexName)UpdateIndexService.ResultpatchDocument(String index, Document doc)Map<String,UpdateIndexService.Result>patchDocuments(String indexName, List<Document> documents)Partial update of an existing document.UpdateIndexService.ResultputDocument(String indexName, Boolean replaceExisting, Document doc)Map<String,UpdateIndexService.Result>putDocuments(String indexName, Boolean replaceExisting, List<Document> documents)Puts a document to the index.ImportSessionstartImport(String indexName, String locale)Start a new full import.protected abstract voidvalidateSession(ImportSession session)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.cxp.ocs.api.indexer.UpdateIndexService
deleteDocuments
-
-
-
-
Constructor Detail
-
AbstractIndexer
public AbstractIndexer(@NonNull @NonNull List<DocumentPreProcessor> dataPreProcessors, @NonNull @NonNull List<DocumentPostProcessor> postProcessors, @NonNull @NonNull FieldConfigIndex fieldConfIndex)
-
-
Method Detail
-
startImport
public ImportSession startImport(String indexName, String locale) throws IllegalStateException
Description copied from interface:FullIndexationServiceStart a new full import. Returns a handle containing meta data, that has to be passed to all following calls.- Specified by:
startImportin interfaceFullIndexationService- Parameters:
indexName- index name, that should match the regular expression '[a-z0-9_-]+'locale- used for language dependent settings- Returns:
ImportSessionthat should be used for follow up requests to add data to that new index- Throws:
IllegalStateException- in case there is already a full-import running for that index.
-
isImportRunning
public abstract boolean isImportRunning(String indexName)
-
initNewIndex
protected abstract String initNewIndex(String indexName, String locale) throws IOException
- Throws:
IOException
-
add
public int add(BulkImportData data) throws Exception
Description copied from interface:FullIndexationServiceAdd one or more documents to a running import session.- Specified by:
addin interfaceFullIndexationService- Parameters:
data- bulk data which consist of theImportSessionand one or more products that should be added to that index.- Returns:
- the amount of documents that were successfully added to the index
- Throws:
Exception- in case import session is invalid
-
addToIndex
protected abstract int addToIndex(ImportSession session, List<IndexableItem> bulk) throws Exception
- Throws:
Exception
-
validateSession
protected abstract void validateSession(ImportSession session) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
done
public boolean done(ImportSession session) throws Exception
Description copied from interface:FullIndexationServiceFinishes the import, flushing the new index and (in case there is already an index with the initialized name) replacing the old one.- Specified by:
donein interfaceFullIndexationService- Parameters:
session- ImportSession that should be closed.- Returns:
- true on success, otherwise false
- Throws:
Exception- if import session is invalid
-
deploy
protected abstract boolean deploy(ImportSession session)
-
cancel
public void cancel(ImportSession session)
Description copied from interface:FullIndexationServiceCancels import which results in a deletion of the temporary index.- Specified by:
cancelin interfaceFullIndexationService- Parameters:
session- ImportSession that contains the information, which index should be dropped.
-
deleteIndex
protected abstract void deleteIndex(String indexName)
-
_get
protected abstract Document _get(@NonNull @NonNull String indexName, @NonNull @NonNull String docId)
-
patchDocuments
public Map<String,UpdateIndexService.Result> patchDocuments(String indexName, List<Document> documents)
Description copied from interface:UpdateIndexServicePartial update of an existing document. If the document does not exist, no update will be performed and status 404 is returned.
In case the document is a master product with variants, the provided master product may only contain the changed values. However if some data at the product variants are updated, all data from all variant products are required, otherwise missing variants won't be there after the update!
- Specified by:
patchDocumentsin interfaceUpdateIndexService- Parameters:
indexName- name of the index that should receive that updatedocuments- Full or partial document that carries the data for the update- Returns:
- Result code, one of UPDATED, NOT_FOUND, NOOP, DISMISSED
-
patchDocument
public UpdateIndexService.Result patchDocument(String index, Document doc)
-
_patch
protected abstract UpdateIndexService.Result _patch(String index, IndexableItem indexableItem)
-
putDocuments
public Map<String,UpdateIndexService.Result> putDocuments(String indexName, Boolean replaceExisting, List<Document> documents)
Description copied from interface:UpdateIndexServicePuts a document to the index. If document does not exist, it will be added.
An existing product will be overwritten unless the parameter "replaceExisting" is set to "false".
Provided document should be a complete object, partial updates should be done using the updateDocument method.
- Specified by:
putDocumentsin interfaceUpdateIndexService- Parameters:
indexName- name of the index that should receive that updatereplaceExisting- set to false to avoid overriding a document with that ID. Defaults to 'true'documents- The documents that should be added or updated at the index.- Returns:
- Result code, one of CREATED, UPDATED, NOOP, DISMISSED
-
putDocument
public UpdateIndexService.Result putDocument(String indexName, Boolean replaceExisting, Document doc)
-
_put
protected abstract UpdateIndexService.Result _put(String indexName, Boolean replaceExisting, IndexableItem indexableItem)
-
-