Package de.cxp.ocs.client
Class ImportClient
java.lang.Object
de.cxp.ocs.client.ImportClient
- All Implemented Interfaces:
FullIndexationService,UpdateIndexService
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.cxp.ocs.api.indexer.UpdateIndexService
UpdateIndexService.Result -
Constructor Summary
ConstructorsConstructorDescriptionImportClient(String endpointUrl) Initializes the SearchClient with the given endpointUrl and the default Jackson encoder.ImportClient(String endpointUrl, Consumer<feign.Feign.Builder> feignConfigurer) With this constructor the Feign::Builder can be configured. -
Method Summary
Modifier and TypeMethodDescriptionintadd(BulkImportData data) Add one or more documents to a running import session.voidcancel(ImportSession session) Cancels import which results in a deletion of the temporary index.deleteDocuments(String indexName, List<String> ids) Delete existing document.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.patchDocuments(String indexName, List<Document> docs) Patch one or more documents.voidpatchProducts(String indexName, List<Product> products) Similar to patchDocuments, but for the extended sub typeProductthat supports variants.Add or overwrite existing documents.Similar to putDocuments, but for the extended sub typeProductthat supports variants.startImport(String indexName, String locale) Start a new full import.
-
Constructor Details
-
ImportClient
With this constructor the Feign::Builder can be configured.- Parameters:
endpointUrl-feignConfigurer-
-
ImportClient
Initializes the SearchClient with the given endpointUrl and the default Jackson encoder. If this constructor is not used, Jackson is not necessary on the classpath. Instead take care of a workingDecoder.- Parameters:
endpointUrl-
-
-
Method Details
-
patchDocuments
Patch one or more documents. The passed documents only need partial data that needs to be patched and the ID of the documents to patch.Attention: in order to patch Products with variants, use the "patchProducts" method, which is necessary to have them serialized properly.
- Specified by:
patchDocumentsin interfaceUpdateIndexService- Parameters:
indexName- name of the index that should receive that updatedocs- Full or partial document that carries the data for the update- Returns:
- Result code, one of UPDATED, NOT_FOUND, NOOP, DISMISSED
-
patchProducts
Similar to patchDocuments, but for the extended sub typeProductthat supports variants. For some reason this is necessary. XXX: may be solved with custom serializer.- Parameters:
indexName-products-
-
putDocuments
public Map<String,UpdateIndexService.Result> putDocuments(String indexName, Boolean replaceExisting, String langCode, List<Document> docs) Add or overwrite existing documents.Attention: in order to put Products with variants, use the "putProducts" method, which is necessary to have them serialized properly.
- 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'docs- The documents that should be added or updated at the index.- Returns:
- Result code, one of CREATED, UPDATED, NOOP, DISMISSED
-
putProducts
public Map<String,UpdateIndexService.Result> putProducts(String indexName, Boolean replaceExisting, String langCode, List<Product> products) Similar to putDocuments, but for the extended sub typeProductthat supports variants.- Parameters:
indexName-replaceExisting-products-- Returns:
-
deleteDocuments
Description copied from interface:UpdateIndexServiceDelete existing document. If document does not exist, it returns code 404.- Specified by:
deleteDocumentsin interfaceUpdateIndexService- Parameters:
indexName- name of the index that should receive that updateids- Array of IDs of the documents that should be deleted- Returns:
- Result code, one of DELETED, NOT_FOUND
-
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.
-
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
-
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
- Throws:
Exception- if import session is invalid
-
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.
-