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 TypeMethodDescriptionint
add
(BulkImportData data) Add one or more documents to a running import session.void
cancel
(ImportSession session) Cancels import which results in a deletion of the temporary index.deleteDocuments
(String indexName, List<String> ids) Delete existing document.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.patchDocuments
(String indexName, List<Document> docs) Patch one or more documents.patchProducts
(String indexName, List<Product> products) Similar to patchDocuments, but for the extended sub typeProduct
that supports variants.Add or overwrite existing documents.Similar to putDocuments, but for the extended sub typeProduct
that 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:
patchDocuments
in 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 typeProduct
that supports variants. For some reason this is necessary. XXX: may be solved with custom serializer.- Parameters:
indexName
-products
-- Returns:
-
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:
putDocuments
in 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 typeProduct
that supports variants.- Parameters:
indexName
-replaceExisting
-products
-- Returns:
-
deleteDocuments
Description copied from interface:UpdateIndexService
Delete existing document. If document does not exist, it returns code 404.- Specified by:
deleteDocuments
in 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: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.
-
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
-
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
-
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.
-