Package de.cxp.ocs.client
Class ImportClient
- java.lang.Object
-
- de.cxp.ocs.client.ImportClient
-
- All Implemented Interfaces:
FullIndexationService,UpdateIndexService
public class ImportClient 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 ImportClient(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intadd(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.Map<String,UpdateIndexService.Result>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.Map<String,UpdateIndexService.Result>patchDocuments(String indexName, List<Document> docs)Patch one or more documents.Map<String,UpdateIndexService.Result>patchProducts(String indexName, List<Product> products)Similar to patchDocuments, but for the extended sub typeProductthat supports variants.Map<String,UpdateIndexService.Result>putDocuments(String indexName, Boolean replaceExisting, List<Document> docs)Add or overwrite existing documents.Map<String,UpdateIndexService.Result>putProducts(String indexName, Boolean replaceExisting, List<Product> products)Similar to putDocuments, but for the extended sub typeProductthat supports variants.ImportSessionstartImport(String indexName, String locale)Start a new full import.
-
-
-
Constructor Detail
-
ImportClient
public ImportClient(String endpointUrl, Consumer<feign.Feign.Builder> feignConfigurer)
With this constructor the Feign::Builder can be configured.- Parameters:
endpointUrl-feignConfigurer-
-
ImportClient
public ImportClient(String endpointUrl)
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 Detail
-
patchDocuments
public Map<String,UpdateIndexService.Result> patchDocuments(String indexName, List<Document> docs)
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
public Map<String,UpdateIndexService.Result> patchProducts(String indexName, List<Product> products)
Similar to patchDocuments, but for the extended sub typeProductthat supports variants. For some reason this is necessary. TODO: may be solved with customer serializer.- Parameters:
indexName-products-- Returns:
-
putDocuments
public Map<String,UpdateIndexService.Result> putDocuments(String indexName, Boolean replaceExisting, 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, List<Product> products)
Similar to putDocuments, but for the extended sub typeProductthat supports variants.- Parameters:
indexName-replaceExisting-products-- Returns:
-
deleteDocuments
public Map<String,UpdateIndexService.Result> deleteDocuments(String indexName, List<String> ids)
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
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.
-
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
-
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
-
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.
-
-