Class ImportClient

java.lang.Object
de.cxp.ocs.client.ImportClient
All Implemented Interfaces:
FullIndexationService, UpdateIndexService

public class ImportClient extends Object implements FullIndexationService, UpdateIndexService
  • Constructor Details

    • 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 working Decoder.
      Parameters:
      endpointUrl -
  • Method Details

    • 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:
      patchDocuments in interface UpdateIndexService
      Parameters:
      indexName - name of the index that should receive that update
      docs - 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 type Product 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 interface UpdateIndexService
      Parameters:
      indexName - name of the index that should receive that update
      replaceExisting - 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 type Product that supports variants.
      Parameters:
      indexName -
      replaceExisting -
      products -
      Returns:
    • deleteDocuments

      public Map<String,UpdateIndexService.Result> deleteDocuments(String indexName, List<String> ids)
      Description copied from interface: UpdateIndexService
      Delete existing document. If document does not exist, it returns code 404.
      Specified by:
      deleteDocuments in interface UpdateIndexService
      Parameters:
      indexName - name of the index that should receive that update
      ids - 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: 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 interface FullIndexationService
      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

      public int add(BulkImportData data) throws Exception
      Description copied from interface: FullIndexationService
      Add one or more documents to a running import session.
      Specified by:
      add in interface FullIndexationService
      Parameters:
      data - bulk data which consist of the ImportSession 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

      public boolean done(ImportSession session) throws Exception
      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 interface FullIndexationService
      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: FullIndexationService
      Cancels import which results in a deletion of the temporary index.
      Specified by:
      cancel in interface FullIndexationService
      Parameters:
      session - ImportSession that contains the information, which index should be dropped.