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
ConstructorsConstructorDescriptionAbstractIndexer(@NonNull List<DocumentPreProcessor> dataPreProcessors, @NonNull List<DocumentPostProcessor> postProcessors, @NonNull FieldConfigIndex fieldConfIndex) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Documentprotected 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 voidcleanupAbandonedImports(String indexName, int minAgeSeconds) 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.abstract booleanindexExists(String indexName) protected abstract StringinitNewIndex(String indexName, String locale) abstract booleanisImportRunning(String indexName) Checks if an active import session exists for that index.patchDocument(String index, Document doc) patchDocuments(String indexName, List<Document> documents) Partial update of an existing document.putDocument(String indexName, Boolean replaceExisting, Document doc) Put documents into existing index.putDocuments(String indexName, Boolean replaceExisting, List<Document> documents) startImport(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, waitMethods inherited from interface de.cxp.ocs.api.indexer.UpdateIndexService
deleteDocuments
-
Constructor Details
-
AbstractIndexer
public AbstractIndexer(@NonNull @NonNull List<DocumentPreProcessor> dataPreProcessors, @NonNull @NonNull List<DocumentPostProcessor> postProcessors, @NonNull @NonNull FieldConfigIndex fieldConfIndex)
-
-
Method Details
-
startImport
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.
-
cleanupAbandonedImports
-
indexExists
-
isImportRunning
Checks if an active import session exists for that index.
This could either be the full internal or the minimal/final index name.
- Parameters:
indexName- internal or external index name- Returns:
-
initNewIndex
- Throws:
IOException
-
add
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
- Throws:
Exception
-
validateSession
- Throws:
IllegalArgumentException
-
done
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
-
deploy
-
cancel
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
-
_get
-
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
-
_patch
-
putDocuments
public Map<String,UpdateIndexService.Result> putDocuments(String indexName, Boolean replaceExisting, String langCode, List<Document> documents) Put documents into existing index. langCode is ignored.- Specified by:
putDocumentsin interfaceUpdateIndexService- Parameters:
indexName- name of existing indexreplaceExisting- set to true, if an existing document with the same ID should be replaced.langCode- ignoreddocuments- list of documents that should be put into index- Returns:
- map of results with one entry per given document, with the document IDs as key
-
putDocuments
-
putDocument
public UpdateIndexService.Result putDocument(String indexName, Boolean replaceExisting, Document doc) -
_put
protected abstract UpdateIndexService.Result _put(String indexName, Boolean replaceExisting, IndexableItem indexableItem)
-