public class IndexingServiceImpl extends Object implements IndexingService, LowLevelIndexingService
| Modifier and Type | Field and Description |
|---|---|
protected SpringAsyncHistoryExecutor |
asyncHistoryExecutor |
protected List<BulkIndexRequestInterceptor> |
bulkIndexRequestInterceptors |
protected ElasticsearchClient |
elasticsearchClient |
protected boolean |
indexingEnabled |
protected IndexManager |
indexManager |
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
protected ObjectSerializationService |
objectSerializationService |
| Constructor and Description |
|---|
IndexingServiceImpl(boolean indexingEnabled,
ElasticsearchClient elasticsearchClient,
ObjectSerializationService objectSerializationService,
IndexManager indexManager,
com.fasterxml.jackson.databind.ObjectMapper objectMapper,
SpringAsyncHistoryExecutor asyncHistoryExecutor,
List<BulkIndexRequestInterceptor> bulkIndexRequestInterceptors) |
| Modifier and Type | Method and Description |
|---|---|
void |
addToCurrentBulkRequestAsFullIndex(CommandContext commandContext,
String type,
String id,
com.fasterxml.jackson.databind.node.ObjectNode data,
String idFieldName)
Adds the
ObjectNode data as a full index (i.e. |
void |
addToCurrentBulkRequestAsFullIndexWithExternalVersion(CommandContext commandContext,
String type,
String id,
com.fasterxml.jackson.databind.node.ObjectNode data,
String idFieldName)
Equivalent to
LowLevelIndexingService.addToCurrentBulkRequestAsFullIndex(CommandContext, String, String, ObjectNode, String),
but using external versioning (vs the one from Elasticsearch). |
void |
addToCurrentBulkRequestAsUpsert(CommandContext commandContext,
com.fasterxml.jackson.databind.node.ObjectNode data,
String idFieldName)
Adds the
ObjectNode data as an upsert (i.e. |
void |
addToCurrentBulkRequestAsUpsertWithScript(CommandContext commandContext,
com.fasterxml.jackson.databind.node.ObjectNode dataNode,
com.fasterxml.jackson.databind.node.ObjectNode scriptNode,
String idFieldName)
Adds the
ObjectNode data as an upsert (i.e. |
protected HistoryJobEntity |
createHistoryJobEntity(String handlerType) |
void |
deleteByQuery(String aliasName,
com.fasterxml.jackson.databind.node.ObjectNode query)
Delete indexed objects based on a query.
|
void |
deleteIndexedObject(String aliasName,
String id)
Delete the indexed object using the provided id.
|
protected String |
determineIndex(IndexMapping indexMapping) |
protected String |
determineIndex(com.fasterxml.jackson.databind.node.ObjectNode objectNode,
IndexedDataObject indexedDataObject) |
void |
indexObject(Object object,
String idFieldName)
Similar to
LowLevelIndexingService.indexObject(Object), but by providing an alternative field name that contains the id,
instead of depending on the IndexingJsonConstants.PROPERTY_ID in the json. |
boolean |
isFullIndexRegisteredOnCurrentBulkRequest(CommandContext commandContext,
String type,
String id)
Returns whether a full index was already registered before during the current transaction.
|
boolean |
isIndexingEnabled() |
void |
scheduleIndexedObjectDelete(String aliasName,
String id)
Schedule a delete of an object from an index.
|
void |
scheduleIndexing(Object object,
String tenantId)
Schedule to index a generic object, that will pass the
IndexableObjectSerializer first. |
void |
scheduleIndexing(String type,
com.fasterxml.jackson.databind.node.ObjectNode dataNode,
String tenantId)
Schedule the json directly to be indexed using the provided type.
|
void |
scheduleUpdateByQuery(String mappingType,
com.fasterxml.jackson.databind.node.ObjectNode updateByQueryBody)
Schedule an update by query with an abitrary body.
|
protected com.fasterxml.jackson.databind.node.ObjectNode |
serializeObject(Object object) |
protected List<IndexedDataObject> |
transformObjectToIndexedDataObjects(com.fasterxml.jackson.databind.node.ObjectNode objectNode,
String idFieldName) |
void |
updateByQuery(String mappingType,
com.fasterxml.jackson.databind.node.ObjectNode data)
Perform Update by Query for the given Mapping type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitindexObjectprotected boolean indexingEnabled
protected ElasticsearchClient elasticsearchClient
protected ObjectSerializationService objectSerializationService
protected IndexManager indexManager
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected SpringAsyncHistoryExecutor asyncHistoryExecutor
protected List<BulkIndexRequestInterceptor> bulkIndexRequestInterceptors
public IndexingServiceImpl(boolean indexingEnabled,
ElasticsearchClient elasticsearchClient,
ObjectSerializationService objectSerializationService,
IndexManager indexManager,
com.fasterxml.jackson.databind.ObjectMapper objectMapper,
SpringAsyncHistoryExecutor asyncHistoryExecutor,
List<BulkIndexRequestInterceptor> bulkIndexRequestInterceptors)
public boolean isIndexingEnabled()
isIndexingEnabled in interface IndexingServicepublic void indexObject(Object object, String idFieldName)
LowLevelIndexingServiceLowLevelIndexingService.indexObject(Object), but by providing an alternative field name that contains the id,
instead of depending on the IndexingJsonConstants.PROPERTY_ID in the json.indexObject in interface LowLevelIndexingServiceprotected List<IndexedDataObject> transformObjectToIndexedDataObjects(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String idFieldName)
protected com.fasterxml.jackson.databind.node.ObjectNode serializeObject(Object object)
public void scheduleIndexing(Object object, String tenantId)
IndexingServiceIndexableObjectSerializer first.scheduleIndexing in interface IndexingServicepublic void scheduleIndexing(String type, com.fasterxml.jackson.databind.node.ObjectNode dataNode, String tenantId)
IndexingServicescheduleIndexing in interface IndexingServicepublic void deleteIndexedObject(String aliasName, String id)
LowLevelIndexingServicedeleteIndexedObject in interface LowLevelIndexingServicepublic void deleteByQuery(String aliasName, com.fasterxml.jackson.databind.node.ObjectNode query)
LowLevelIndexingServicedeleteByQuery in interface LowLevelIndexingServicepublic void scheduleUpdateByQuery(String mappingType, com.fasterxml.jackson.databind.node.ObjectNode updateByQueryBody)
IndexingServicescheduleUpdateByQuery in interface IndexingServicepublic void updateByQuery(String mappingType, com.fasterxml.jackson.databind.node.ObjectNode data)
LowLevelIndexingServiceupdateByQuery in interface LowLevelIndexingServicemappingType - the type of the mapping for which the update should be donedata - the update by query request datapublic void scheduleIndexedObjectDelete(String aliasName, String id)
IndexingServicescheduleIndexedObjectDelete in interface IndexingServicepublic void addToCurrentBulkRequestAsUpsert(CommandContext commandContext, com.fasterxml.jackson.databind.node.ObjectNode data, String idFieldName)
LowLevelIndexingServiceObjectNode data as an upsert (i.e. merge if exist, insert if not)
to the current bulk request (or creates a bulk request if needed).
The bulk request is executed at the end of the transactions, when all items for indexing have been added.addToCurrentBulkRequestAsUpsert in interface LowLevelIndexingServicepublic void addToCurrentBulkRequestAsFullIndex(CommandContext commandContext, String type, String id, com.fasterxml.jackson.databind.node.ObjectNode data, String idFieldName)
LowLevelIndexingServiceObjectNode data as a full index (i.e. replace the current indexed document if any exists)
to the current bulk request (or creates a bulk request if needed).
The bulk request is executed at the end of the transactions, when all items for indexing have been added.
The {type, id} parameters are not used during indexing, but is registered internally and can be used to check
whether indexing was already triggered via the LowLevelIndexingService.isFullIndexRegisteredOnCurrentBulkRequest(CommandContext, String, String) method.
This allows to avoid costly recalculation of data or doing the same indexing operation multiple times in ES.
Note that this method doesn't apply that check automatically, and the caller is responsible for calling it.addToCurrentBulkRequestAsFullIndex in interface LowLevelIndexingServicepublic void addToCurrentBulkRequestAsFullIndexWithExternalVersion(CommandContext commandContext, String type, String id, com.fasterxml.jackson.databind.node.ObjectNode data, String idFieldName)
LowLevelIndexingServiceLowLevelIndexingService.addToCurrentBulkRequestAsFullIndex(CommandContext, String, String, ObjectNode, String),
but using external versioning (vs the one from Elasticsearch).addToCurrentBulkRequestAsFullIndexWithExternalVersion in interface LowLevelIndexingServicepublic void addToCurrentBulkRequestAsUpsertWithScript(CommandContext commandContext, com.fasterxml.jackson.databind.node.ObjectNode dataNode, com.fasterxml.jackson.databind.node.ObjectNode scriptNode, String idFieldName)
LowLevelIndexingServiceObjectNode data as an upsert (i.e. merge if exist, insert if not) using an update script
to the current bulk request (or creates a bulk request if needed).
The bulk request is executed at the end of the transactions, when all items for indexing have been added.addToCurrentBulkRequestAsUpsertWithScript in interface LowLevelIndexingServicepublic boolean isFullIndexRegisteredOnCurrentBulkRequest(CommandContext commandContext, String type, String id)
LowLevelIndexingServiceLowLevelIndexingService.addToCurrentBulkRequestAsFullIndex(CommandContext, String, String, ObjectNode, String) method.isFullIndexRegisteredOnCurrentBulkRequest in interface LowLevelIndexingServiceprotected String determineIndex(com.fasterxml.jackson.databind.node.ObjectNode objectNode, IndexedDataObject indexedDataObject)
protected String determineIndex(IndexMapping indexMapping)
protected HistoryJobEntity createHistoryJobEntity(String handlerType)