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 Document
protected abstract UpdateIndexService.Result
_patch
(String index, IndexableItem indexableItem) protected abstract UpdateIndexService.Result
_put
(String indexName, Boolean replaceExisting, IndexableItem indexableItem) int
add
(BulkImportData data) Add one or more documents to a running import session.protected abstract int
addToIndex
(ImportSession session, List<IndexableItem> bulk) void
cancel
(ImportSession session) Cancels import which results in a deletion of the temporary index.protected abstract void
cleanupAbandonedImports
(String indexName, int minAgeSeconds) protected abstract void
deleteIndex
(String indexName) protected abstract boolean
deploy
(ImportSession session) boolean
done
(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 boolean
indexExists
(String indexName) protected abstract String
initNewIndex
(String indexName, String locale) abstract boolean
isImportRunning
(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 void
validateSession
(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 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:FullIndexationService
Start a new full import. Returns a handle containing meta data, that has to be passed to all following calls.- Specified by:
startImport
in interfaceFullIndexationService
- Parameters:
indexName
- index name, that should match the regular expression '[a-z0-9_-]+'locale
- used for language dependent settings- Returns:
ImportSession
that 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:FullIndexationService
Add one or more documents to a running import session.- Specified by:
add
in interfaceFullIndexationService
- Parameters:
data
- bulk data which consist of theImportSession
and 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:FullIndexationService
Finishes the import, flushing the new index and (in case there is already an index with the initialized name) replacing the old one.- Specified by:
done
in interfaceFullIndexationService
- Parameters:
session
- ImportSession that should be closed.- Returns:
- true on success, otherwise false
- Throws:
Exception
- if import session is invalid
-
deploy
-
cancel
Description copied from interface:FullIndexationService
Cancels import which results in a deletion of the temporary index.- Specified by:
cancel
in 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:UpdateIndexService
Partial 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:
patchDocuments
in 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:
putDocuments
in 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)
-