Class ElasticSearchPersistenceServiceImpl
- java.lang.Object
-
- org.apache.unomi.persistence.elasticsearch.ElasticSearchPersistenceServiceImpl
-
- All Implemented Interfaces:
EventListener,PersistenceService,org.osgi.framework.BundleListener,org.osgi.framework.SynchronousBundleListener
public class ElasticSearchPersistenceServiceImpl extends Object implements PersistenceService, org.osgi.framework.SynchronousBundleListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classElasticSearchPersistenceServiceImpl.InClassLoaderExecute<T>
-
Field Summary
Fields Modifier and Type Field Description static StringBULK_PROCESSOR_BACKOFF_POLICYstatic StringBULK_PROCESSOR_BULK_SIZEstatic StringBULK_PROCESSOR_FLUSH_INTERVALstatic StringPRIMARY_TERMstatic StringSEQ_NO
-
Constructor Summary
Constructors Constructor Description ElasticSearchPersistenceServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Map<String,Long>aggregateQuery(Condition filter, BaseAggregate aggregate, String itemType)Deprecated.As of version 1.3.0-incubating, useaggregateWithOptimizedQuery(Condition, BaseAggregate, String)insteadMap<String,Long>aggregateWithOptimizedQuery(Condition filter, BaseAggregate aggregate, String itemType)Retrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPEmatching the optional specified condition and aggregated according to the specifiedBaseAggregate.Map<String,Long>aggregateWithOptimizedQuery(Condition filter, BaseAggregate aggregate, String itemType, int size)Retrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPEmatching the optional specified condition and aggregated according to the specifiedBaseAggregate.voidbindConditionESQueryBuilder(org.osgi.framework.ServiceReference<ConditionESQueryBuilder> conditionESQueryBuilderServiceReference)voidbindConditionEvaluator(org.osgi.framework.ServiceReference<ConditionEvaluator> conditionEvaluatorServiceReference)voidbundleChanged(org.osgi.framework.BundleEvent event)PartialList<CustomItem>continueCustomItemScrollQuery(String customItemType, String scrollIdentifier, String scrollTimeValidity)Continues the execution of a scroll query, to retrieve the next results.<T extends Item>
PartialList<T>continueScrollQuery(Class<T> clazz, String scrollIdentifier, String scrollTimeValidity)Continues the execution of a scroll query, to retrieve the next results.booleancreateIndex(String itemType)Creates an index with for the specified item type in the persistence engine.voidcreateMapping(String type, String source)Create mapping<T extends Item>
List<T>getAllItems(Class<T> clazz)Retrieves all known items of the specified class.<T extends Item>
PartialList<T>getAllItems(Class<T> clazz, int offset, int size, String sortBy)Retrieves all known items of the specified class, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.<T extends Item>
PartialList<T>getAllItems(Class<T> clazz, int offset, int size, String sortBy, String scrollTimeValidity)Retrieves all known items of the specified class, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.longgetAllItemsCount(String itemType)Retrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPE.org.elasticsearch.action.bulk.BulkProcessorgetBulkProcessor()Map<String,Map<String,Object>>getPropertiesMapping(String itemType)Retrieve the type mappings for a given itemType.Map<String,Object>getPropertyMapping(String property, String itemType)Retrieve the mapping for one specific property for a given type.Map<String,Double>getSingleValuesMetrics(Condition condition, String[] metrics, String field, String itemType)Retrieves the specified metrics for the specified field of items of the specified type as defined by the Item subclass public fieldITEM_TYPEand matching the specifiedCondition.booleanindexTemplateExists(String templateName)booleanisConsistent(Item item)Return true if the item which is saved in the persistence service is consistentbooleanisValidCondition(Condition condition, Item item)validates if a condition throws exception at query build.<T extends Item>
Tload(String itemId, Class<T> clazz)Retrieves the item identified with the specified identifier and with the specified Item subclass if it exists.<T extends Item>
Tload(String itemId, Date dateHint, Class<T> clazz)Deprecated.CustomItemloadCustomItem(String itemId, String customItemType)Load a custom item type identified by an identifier, an optional date hint and the identifier of the custom item typeCustomItemloadCustomItem(String itemId, Date dateHint, String customItemType)Deprecated.voidpurge(String scope)Removes all data associated with the provided scope.voidpurge(Date date)deprecated: (use: purgeTimeBasedItems instead)<T extends Item>
voidpurgeTimeBasedItems(int existsNumberOfDays, Class<T> clazz)Purges time based data in the context server up to the specified days number of existence.<T extends Item>
List<T>query(String fieldName, String[] fieldValues, String sortBy, Class<T> clazz)Retrieves a list of items with the specified field having the specified values.<T extends Item>
List<T>query(String fieldName, String fieldValue, String sortBy, Class<T> clazz)Same asquery(fieldName, fieldValue, sortBy, clazz, 0, -1).getList()<T extends Item>
PartialList<T>query(String fieldName, String fieldValue, String sortBy, Class<T> clazz, int offset, int size)Retrieves a list of items with the specified field having the specified value.<T extends Item>
List<T>query(Condition query, String sortBy, Class<T> clazz)Same asquery(query, sortBy, clazz, 0, -1).getList()<T extends Item>
PartialList<T>query(Condition query, String sortBy, Class<T> clazz, int offset, int size)Retrieves a list of items satisfying the specifiedCondition, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.<T extends Item>
PartialList<T>query(Condition query, String sortBy, Class<T> clazz, int offset, int size, String scrollTimeValidity)Retrieves a list of items satisfying the specifiedCondition, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.longqueryCount(Condition query, String itemType)Retrieves the number of items of the specified type as defined by the Item subclass public fieldITEM_TYPEand matching the specifiedCondition.PartialList<CustomItem>queryCustomItem(Condition query, String sortBy, String customItemType, int offset, int size, String scrollTimeValidity)Retrieves a list of items satisfying the specifiedCondition, ordered according to the specifiedsortByString and paged: onlysizeof them are retrieved, starting with theoffset-th one.<T extends Item>
PartialList<T>queryFullText(String fulltext, String sortBy, Class<T> clazz, int offset, int size)Retrieves a list of items having at least a field with the specified full text value in it, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.<T extends Item>
PartialList<T>queryFullText(String fieldName, String fieldValue, String fulltext, String sortBy, Class<T> clazz, int offset, int size)Retrieves a list of items with the specified field having the specified value and having at least a field with the specified full text value in it, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.<T extends Item>
PartialList<T>queryFullText(String fulltext, Condition query, String sortBy, Class<T> clazz, int offset, int size)Retrieves the same items asquery(query, sortBy, clazz, 0, -1)with the added constraints that the matching elements must also have at least a field matching the specified full text query.<T extends Item>
PartialList<T>rangeQuery(String fieldName, String from, String to, String sortBy, Class<T> clazz, int offset, int size)Retrieves all items of the specified Item subclass which specified ranged property is within the specified bounds, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.voidrefresh()Updates the persistence's engine indices if needed.<T extends Item>
voidrefreshIndex(Class<T> clazz, Date dateHint)booleanregisterRolloverLifecyclePolicy()<T extends Item>
booleanremove(String itemId, Class<T> clazz)Deletes the item identified with the specified identifier and with the specified Item subclass if it exists.<T extends Item>
booleanremoveByQuery(Condition query, Class<T> clazz)Deletes items with the specified Item subclass matching the specifiedCondition.<T extends Item>
booleanremoveByQuery(org.elasticsearch.index.query.QueryBuilder queryBuilder, Class<T> clazz)booleanremoveCustomItem(String itemId, String customItemType)Remove a custom item identified by the custom item identifier and the custom item type identifierbooleanremoveIndex(String itemType)Removes the index for the specified item type.booleanremoveIndexTemplate(String templateName)booleanremoveQuery(String queryName)Deletes the query identified by the specified name.booleansave(Item item)Persists the specified Item in the context server.booleansave(Item item, boolean useBatching)Persists the specified Item in the context server.booleansave(Item item, Boolean useBatchingOption, Boolean alwaysOverwriteOption)Persists the specified Item in the context server.booleansaveQuery(String queryName, String query)booleansaveQuery(String queryName, Condition query)Persists the specified query under the specified name.voidsetAggQueryMaxResponseSizeHttp(String aggQueryMaxResponseSizeHttp)voidsetAggQueryThrowOnMissingDocs(boolean aggQueryThrowOnMissingDocs)voidsetAggregateQueryBucketSize(int aggregateQueryBucketSize)voidsetAlwaysOverwrite(boolean alwaysOverwrite)voidsetBulkProcessorBackoffPolicy(String bulkProcessorBackoffPolicy)voidsetBulkProcessorBulkActions(String bulkProcessorBulkActions)voidsetBulkProcessorBulkSize(String bulkProcessorBulkSize)voidsetBulkProcessorConcurrentRequests(String bulkProcessorConcurrentRequests)voidsetBulkProcessorFlushInterval(String bulkProcessorFlushInterval)voidsetBundleContext(org.osgi.framework.BundleContext bundleContext)voidsetClientSocketTimeout(String clientSocketTimeout)voidsetClusterName(String clusterName)voidsetConditionESQueryBuilderDispatcher(ConditionESQueryBuilderDispatcher conditionESQueryBuilderDispatcher)voidsetConditionEvaluatorDispatcher(ConditionEvaluatorDispatcher conditionEvaluatorDispatcher)voidsetDefaultQueryLimit(Integer defaultQueryLimit)voidsetElasticSearchAddresses(String elasticSearchAddresses)voidsetFatalIllegalStateErrors(String fatalIllegalStateErrors)voidsetIndexMappingTotalFieldsLimit(String indexMappingTotalFieldsLimit)voidsetIndexMaxDocValueFieldsSearch(String indexMaxDocValueFieldsSearch)voidsetIndexPrefix(String indexPrefix)voidsetItemsMonthlyIndexedOverride(String itemsMonthlyIndexedOverride)Deprecated.voidsetItemTypeToRefreshPolicy(String itemTypeToRefreshPolicy)voidsetLogLevelRestClient(String logLevelRestClient)voidsetMaximalElasticSearchVersion(String maximalElasticSearchVersion)voidsetMetricsService(MetricsService metricsService)voidsetMinimalElasticSearchVersion(String minimalElasticSearchVersion)voidsetMonthlyIndexMappingTotalFieldsLimit(String monthlyIndexMappingTotalFieldsLimit)Deprecated.voidsetMonthlyIndexMaxDocValueFieldsSearch(String monthlyIndexMaxDocValueFieldsSearch)Deprecated.voidsetMonthlyIndexNumberOfReplicas(String monthlyIndexNumberOfReplicas)Deprecated.voidsetMonthlyIndexNumberOfShards(String monthlyIndexNumberOfShards)Deprecated.voidsetNumberOfReplicas(String numberOfReplicas)voidsetNumberOfShards(String numberOfShards)voidsetPassword(String password)voidsetPropertyMapping(PropertyType property, String itemType)Create the persistence mapping for specific property for a given type.voidsetRolloverIndexMappingTotalFieldsLimit(String rolloverIndexMappingTotalFieldsLimit)voidsetRolloverIndexMaxDocValueFieldsSearch(String rolloverIndexMaxDocValueFieldsSearch)voidsetRolloverIndexNumberOfReplicas(String rolloverIndexNumberOfReplicas)voidsetRolloverIndexNumberOfShards(String rolloverIndexNumberOfShards)voidsetRolloverIndices(String rolloverIndices)voidsetRolloverMaxAge(String rolloverMaxAge)voidsetRolloverMaxDocs(String rolloverMaxDocs)voidsetRolloverMaxSize(String rolloverMaxSize)voidsetRoutingByType(Map<String,String> routingByType)voidsetSslEnable(boolean sslEnable)voidsetSslTrustAllCertificates(boolean sslTrustAllCertificates)voidsetTaskWaitingPollingInterval(String taskWaitingPollingInterval)voidsetTaskWaitingTimeout(String taskWaitingTimeout)voidsetThrowExceptions(boolean throwExceptions)voidsetUseBatchingForSave(boolean useBatchingForSave)voidsetUseBatchingForUpdate(boolean useBatchingForUpdate)voidsetUsername(String username)voidstart()voidstop()booleanstoreScripts(Map<String,String> scripts)Store script in the Database for later usage with updateWithQueryAndStoredScript function for example.booleantestMatch(Condition query, Item item)Checks whether the specified item satisfies the provided condition.voidunbindConditionESQueryBuilder(org.osgi.framework.ServiceReference<ConditionESQueryBuilder> conditionESQueryBuilderServiceReference)voidunbindConditionEvaluator(org.osgi.framework.ServiceReference<ConditionEvaluator> conditionEvaluatorServiceReference)List<String>update(Map<Item,Map> items, Date dateHint, Class clazz)booleanupdate(Item item, Class clazz, String propertyName, Object propertyValue)Updates the item of the specified class and identified by the specified identifier with a new property value for the specified property name.booleanupdate(Item item, Class clazz, Map source)Updates the item of the specified class and identified by the specified identifier with new property values provided as name - value pairs in the specified Map.booleanupdate(Item item, Class clazz, Map source, boolean alwaysOverwrite)Updates the item of the specified class and identified by the specified identifier with new property values provided as name - value pairs in the specified Map.booleanupdate(Item item, Date dateHint, Class clazz, String propertyName, Object propertyValue)booleanupdate(Item item, Date dateHint, Class clazz, Map source)booleanupdate(Item item, Date dateHint, Class clazz, Map source, boolean alwaysOverwrite)booleanupdateWithQueryAndScript(Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)Updates the items of the specified class by a query with a new property value for the specified property name based on provided scripts and script parametersbooleanupdateWithQueryAndScript(Date dateHint, Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)booleanupdateWithQueryAndStoredScript(Class<?>[] classes, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions, boolean waitForComplete)Updates the items of the specified class by a query with a new property value for the specified property name based on provided stored scripts and script parameters, This one is able to perform an update on multiple types in a single run, be careful with your query as it will be performed on all of them.booleanupdateWithQueryAndStoredScript(Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)Updates the items of the specified class by a query with a new property value for the specified property name based on provided stored scripts and script parametersbooleanupdateWithQueryAndStoredScript(Date dateHint, Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)booleanupdateWithScript(Item item, Class<?> clazz, String script, Map<String,Object> scriptParams)Updates the item of the specified class and identified by the specified identifier with a new property value for the specified property name.booleanupdateWithScript(Item item, Date dateHint, Class<?> clazz, String script, Map<String,Object> scriptParams)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.unomi.persistence.spi.PersistenceService
refreshIndex, update
-
-
-
-
Field Detail
-
BULK_PROCESSOR_BULK_SIZE
public static final String BULK_PROCESSOR_BULK_SIZE
- See Also:
- Constant Field Values
-
BULK_PROCESSOR_FLUSH_INTERVAL
public static final String BULK_PROCESSOR_FLUSH_INTERVAL
- See Also:
- Constant Field Values
-
BULK_PROCESSOR_BACKOFF_POLICY
public static final String BULK_PROCESSOR_BACKOFF_POLICY
- See Also:
- Constant Field Values
-
SEQ_NO
public static final String SEQ_NO
- See Also:
- Constant Field Values
-
PRIMARY_TERM
public static final String PRIMARY_TERM
- See Also:
- Constant Field Values
-
-
Method Detail
-
setBundleContext
public void setBundleContext(org.osgi.framework.BundleContext bundleContext)
-
setClusterName
public void setClusterName(String clusterName)
-
setElasticSearchAddresses
public void setElasticSearchAddresses(String elasticSearchAddresses)
-
setItemTypeToRefreshPolicy
public void setItemTypeToRefreshPolicy(String itemTypeToRefreshPolicy) throws IOException
- Throws:
IOException
-
setFatalIllegalStateErrors
public void setFatalIllegalStateErrors(String fatalIllegalStateErrors)
-
setAggQueryMaxResponseSizeHttp
public void setAggQueryMaxResponseSizeHttp(String aggQueryMaxResponseSizeHttp)
-
setIndexPrefix
public void setIndexPrefix(String indexPrefix)
-
setMonthlyIndexNumberOfShards
@Deprecated public void setMonthlyIndexNumberOfShards(String monthlyIndexNumberOfShards)
Deprecated.
-
setMonthlyIndexNumberOfReplicas
@Deprecated public void setMonthlyIndexNumberOfReplicas(String monthlyIndexNumberOfReplicas)
Deprecated.
-
setMonthlyIndexMappingTotalFieldsLimit
@Deprecated public void setMonthlyIndexMappingTotalFieldsLimit(String monthlyIndexMappingTotalFieldsLimit)
Deprecated.
-
setMonthlyIndexMaxDocValueFieldsSearch
@Deprecated public void setMonthlyIndexMaxDocValueFieldsSearch(String monthlyIndexMaxDocValueFieldsSearch)
Deprecated.
-
setItemsMonthlyIndexedOverride
@Deprecated public void setItemsMonthlyIndexedOverride(String itemsMonthlyIndexedOverride)
Deprecated.
-
setNumberOfShards
public void setNumberOfShards(String numberOfShards)
-
setNumberOfReplicas
public void setNumberOfReplicas(String numberOfReplicas)
-
setIndexMappingTotalFieldsLimit
public void setIndexMappingTotalFieldsLimit(String indexMappingTotalFieldsLimit)
-
setIndexMaxDocValueFieldsSearch
public void setIndexMaxDocValueFieldsSearch(String indexMaxDocValueFieldsSearch)
-
setDefaultQueryLimit
public void setDefaultQueryLimit(Integer defaultQueryLimit)
-
setConditionEvaluatorDispatcher
public void setConditionEvaluatorDispatcher(ConditionEvaluatorDispatcher conditionEvaluatorDispatcher)
-
setConditionESQueryBuilderDispatcher
public void setConditionESQueryBuilderDispatcher(ConditionESQueryBuilderDispatcher conditionESQueryBuilderDispatcher)
-
setBulkProcessorConcurrentRequests
public void setBulkProcessorConcurrentRequests(String bulkProcessorConcurrentRequests)
-
setBulkProcessorBulkActions
public void setBulkProcessorBulkActions(String bulkProcessorBulkActions)
-
setBulkProcessorBulkSize
public void setBulkProcessorBulkSize(String bulkProcessorBulkSize)
-
setBulkProcessorFlushInterval
public void setBulkProcessorFlushInterval(String bulkProcessorFlushInterval)
-
setBulkProcessorBackoffPolicy
public void setBulkProcessorBackoffPolicy(String bulkProcessorBackoffPolicy)
-
setRolloverIndices
public void setRolloverIndices(String rolloverIndices)
-
setRolloverMaxSize
public void setRolloverMaxSize(String rolloverMaxSize)
-
setRolloverMaxAge
public void setRolloverMaxAge(String rolloverMaxAge)
-
setRolloverMaxDocs
public void setRolloverMaxDocs(String rolloverMaxDocs)
-
setRolloverIndexNumberOfShards
public void setRolloverIndexNumberOfShards(String rolloverIndexNumberOfShards)
-
setRolloverIndexNumberOfReplicas
public void setRolloverIndexNumberOfReplicas(String rolloverIndexNumberOfReplicas)
-
setRolloverIndexMappingTotalFieldsLimit
public void setRolloverIndexMappingTotalFieldsLimit(String rolloverIndexMappingTotalFieldsLimit)
-
setRolloverIndexMaxDocValueFieldsSearch
public void setRolloverIndexMaxDocValueFieldsSearch(String rolloverIndexMaxDocValueFieldsSearch)
-
setMinimalElasticSearchVersion
public void setMinimalElasticSearchVersion(String minimalElasticSearchVersion)
-
setMaximalElasticSearchVersion
public void setMaximalElasticSearchVersion(String maximalElasticSearchVersion)
-
setAggregateQueryBucketSize
public void setAggregateQueryBucketSize(int aggregateQueryBucketSize)
-
setClientSocketTimeout
public void setClientSocketTimeout(String clientSocketTimeout)
-
setMetricsService
public void setMetricsService(MetricsService metricsService)
-
setUseBatchingForSave
public void setUseBatchingForSave(boolean useBatchingForSave)
-
setUseBatchingForUpdate
public void setUseBatchingForUpdate(boolean useBatchingForUpdate)
-
setUsername
public void setUsername(String username)
-
setPassword
public void setPassword(String password)
-
setSslEnable
public void setSslEnable(boolean sslEnable)
-
setSslTrustAllCertificates
public void setSslTrustAllCertificates(boolean sslTrustAllCertificates)
-
setAggQueryThrowOnMissingDocs
public void setAggQueryThrowOnMissingDocs(boolean aggQueryThrowOnMissingDocs)
-
setThrowExceptions
public void setThrowExceptions(boolean throwExceptions)
-
setAlwaysOverwrite
public void setAlwaysOverwrite(boolean alwaysOverwrite)
-
setLogLevelRestClient
public void setLogLevelRestClient(String logLevelRestClient)
-
setTaskWaitingTimeout
public void setTaskWaitingTimeout(String taskWaitingTimeout)
-
setTaskWaitingPollingInterval
public void setTaskWaitingPollingInterval(String taskWaitingPollingInterval)
-
getBulkProcessor
public org.elasticsearch.action.bulk.BulkProcessor getBulkProcessor()
-
stop
public void stop()
-
bindConditionEvaluator
public void bindConditionEvaluator(org.osgi.framework.ServiceReference<ConditionEvaluator> conditionEvaluatorServiceReference)
-
unbindConditionEvaluator
public void unbindConditionEvaluator(org.osgi.framework.ServiceReference<ConditionEvaluator> conditionEvaluatorServiceReference)
-
bindConditionESQueryBuilder
public void bindConditionESQueryBuilder(org.osgi.framework.ServiceReference<ConditionESQueryBuilder> conditionESQueryBuilderServiceReference)
-
unbindConditionESQueryBuilder
public void unbindConditionESQueryBuilder(org.osgi.framework.ServiceReference<ConditionESQueryBuilder> conditionESQueryBuilderServiceReference)
-
bundleChanged
public void bundleChanged(org.osgi.framework.BundleEvent event)
- Specified by:
bundleChangedin interfaceorg.osgi.framework.BundleListener
-
getAllItems
public <T extends Item> List<T> getAllItems(Class<T> clazz)
Description copied from interface:PersistenceServiceRetrieves all known items of the specified class. WARNING: this method can be quite computationally intensive and calling the paged versionPersistenceService.getAllItems(Class, int, int, String)is preferred.- Specified by:
getAllItemsin interfacePersistenceService- Type Parameters:
T- the type of theItems we want to retrieve- Parameters:
clazz- theItemsubclass of entities we want to retrieve- Returns:
- a list of all known items with the given type
-
getAllItemsCount
public long getAllItemsCount(String itemType)
Description copied from interface:PersistenceServiceRetrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPE.- Specified by:
getAllItemsCountin interfacePersistenceService- Parameters:
itemType- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPEfield- Returns:
- the number of items of the specified type
- See Also:
Item for a discussion of
-
getAllItems
public <T extends Item> PartialList<T> getAllItems(Class<T> clazz, int offset, int size, String sortBy)
Description copied from interface:PersistenceServiceRetrieves all known items of the specified class, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.TODO: use a Query object instead of distinct parameters?
- Specified by:
getAllItemsin interfacePersistenceService- Type Parameters:
T- the type of theItems we want to retrieve- Parameters:
clazz- theItemsubclass of entities we want to retrieveoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrievedsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.- Returns:
- a
PartialListof pages items with the given type
-
getAllItems
public <T extends Item> PartialList<T> getAllItems(Class<T> clazz, int offset, int size, String sortBy, String scrollTimeValidity)
Description copied from interface:PersistenceServiceRetrieves all known items of the specified class, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.TODO: use a Query object instead of distinct parameters?
- Specified by:
getAllItemsin interfacePersistenceService- Type Parameters:
T- the type of theItems we want to retrieve- Parameters:
clazz- theItemsubclass of entities we want to retrieveoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrievedsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.scrollTimeValidity- the time the scrolling query should stay valid. This must contain a time unit value such as the ones supported by ElasticSearch, such as * the ones declared here : https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units- Returns:
- a
PartialListof pages items with the given type
-
load
public <T extends Item> T load(String itemId, Class<T> clazz)
Description copied from interface:PersistenceServiceRetrieves the item identified with the specified identifier and with the specified Item subclass if it exists.- Specified by:
loadin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
itemId- the identifier of the item we want to retrieveclazz- theItemsubclass of the item we want to retrieve- Returns:
- the item identified with the specified identifier and with the specified Item subclass if it exists,
nullotherwise
-
load
@Deprecated public <T extends Item> T load(String itemId, Date dateHint, Class<T> clazz)
Deprecated.- Specified by:
loadin interfacePersistenceService
-
loadCustomItem
@Deprecated public CustomItem loadCustomItem(String itemId, Date dateHint, String customItemType)
Deprecated.- Specified by:
loadCustomItemin interfacePersistenceService
-
loadCustomItem
public CustomItem loadCustomItem(String itemId, String customItemType)
Description copied from interface:PersistenceServiceLoad a custom item type identified by an identifier, an optional date hint and the identifier of the custom item type- Specified by:
loadCustomItemin interfacePersistenceService- Parameters:
itemId- the identifier of the custom type we want to retrievecustomItemType- an identifier of the custom item type to load- Returns:
- the CustomItem instance with the specified identifier and the custom item type if it exists,
nullotherwise
-
isConsistent
public boolean isConsistent(Item item)
Description copied from interface:PersistenceServiceReturn true if the item which is saved in the persistence service is consistent- Specified by:
isConsistentin interfacePersistenceService- Parameters:
item- the item to the check if consistent- Returns:
trueif the item is consistent, false otherwise
-
save
public boolean save(Item item)
Description copied from interface:PersistenceServicePersists the specified Item in the context server.- Specified by:
savein interfacePersistenceService- Parameters:
item- the item to persist- Returns:
trueif the item was properly persisted,falseotherwise
-
save
public boolean save(Item item, boolean useBatching)
Description copied from interface:PersistenceServicePersists the specified Item in the context server.- Specified by:
savein interfacePersistenceService- Parameters:
item- the item to persistuseBatching- whether to use batching or not for saving the item. If activating there may be a delay between the call to this method and the actual saving in the persistence backend.- Returns:
trueif the item was properly persisted,falseotherwise
-
save
public boolean save(Item item, Boolean useBatchingOption, Boolean alwaysOverwriteOption)
Description copied from interface:PersistenceServicePersists the specified Item in the context server.- Specified by:
savein interfacePersistenceService- Parameters:
item- the item to persistuseBatchingOption- whether to use batching or not for saving the item. If activating there may be a delay between the call to this method and the actual saving in the persistence backendalwaysOverwriteOption- whether to overwrite a document even if we are holding an old item when saving- Returns:
trueif the item was properly persisted,falseotherwise
-
update
public boolean update(Item item, Date dateHint, Class clazz, String propertyName, Object propertyValue)
- Specified by:
updatein interfacePersistenceService
-
update
public boolean update(Item item, Date dateHint, Class clazz, Map source)
- Specified by:
updatein interfacePersistenceService
-
update
public boolean update(Item item, Date dateHint, Class clazz, Map source, boolean alwaysOverwrite)
- Specified by:
updatein interfacePersistenceService
-
update
public boolean update(Item item, Class clazz, String propertyName, Object propertyValue)
Description copied from interface:PersistenceServiceUpdates the item of the specified class and identified by the specified identifier with a new property value for the specified property name. Same asupdate(itemId, clazz, Collections.singletonMap(propertyName, propertyValue))- Specified by:
updatein interfacePersistenceService- Parameters:
item- the item we want to updateclazz- the Item subclass of the item to updatepropertyName- the name of the property to updatepropertyValue- the new value of the property- Returns:
trueif the update was successful,falseotherwise
-
update
public boolean update(Item item, Class clazz, Map source)
Description copied from interface:PersistenceServiceUpdates the item of the specified class and identified by the specified identifier with new property values provided as name - value pairs in the specified Map.- Specified by:
updatein interfacePersistenceService- Parameters:
item- the item we want to updateclazz- the Item subclass of the item to updatesource- a Map with entries specifying as key the property name to update and as value its new value- Returns:
trueif the update was successful,falseotherwise
-
update
public boolean update(Item item, Class clazz, Map source, boolean alwaysOverwrite)
Description copied from interface:PersistenceServiceUpdates the item of the specified class and identified by the specified identifier with new property values provided as name - value pairs in the specified Map.- Specified by:
updatein interfacePersistenceService- Parameters:
item- the item we want to updateclazz- the Item subclass of the item to updatesource- a Map with entries specifying as key the property name to update and as value its new valuealwaysOverwrite- whether to overwrite a document even if we are holding an old item when saving- Returns:
trueif the update was successful,falseotherwise
-
update
public List<String> update(Map<Item,Map> items, Date dateHint, Class clazz)
- Specified by:
updatein interfacePersistenceService
-
updateWithQueryAndScript
public boolean updateWithQueryAndScript(Date dateHint, Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)
- Specified by:
updateWithQueryAndScriptin interfacePersistenceService
-
updateWithQueryAndScript
public boolean updateWithQueryAndScript(Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)
Description copied from interface:PersistenceServiceUpdates the items of the specified class by a query with a new property value for the specified property name based on provided scripts and script parameters- Specified by:
updateWithQueryAndScriptin interfacePersistenceService- Parameters:
clazz- the Item subclass of the item to updatescripts- inline scripts arrayscriptParams- script params arrayconditions- conditions array- Returns:
trueif the update was successful,falseotherwise
-
updateWithQueryAndStoredScript
public boolean updateWithQueryAndStoredScript(Date dateHint, Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)
- Specified by:
updateWithQueryAndStoredScriptin interfacePersistenceService
-
updateWithQueryAndStoredScript
public boolean updateWithQueryAndStoredScript(Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)
Description copied from interface:PersistenceServiceUpdates the items of the specified class by a query with a new property value for the specified property name based on provided stored scripts and script parameters- Specified by:
updateWithQueryAndStoredScriptin interfacePersistenceService- Parameters:
clazz- the Item subclass of the item to updatescripts- Stored scripts namescriptParams- script params arrayconditions- conditions array- Returns:
trueif the update was successful,falseotherwise
-
updateWithQueryAndStoredScript
public boolean updateWithQueryAndStoredScript(Class<?>[] classes, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions, boolean waitForComplete)
Description copied from interface:PersistenceServiceUpdates the items of the specified class by a query with a new property value for the specified property name based on provided stored scripts and script parameters, This one is able to perform an update on multiple types in a single run, be careful with your query as it will be performed on all of them.- Specified by:
updateWithQueryAndStoredScriptin interfacePersistenceService- Parameters:
classes- classes of items to update, be careful all of them will be submitted to update for all scripts/conditionsscripts- Stored scripts namescriptParams- script params arrayconditions- conditions arraywaitForComplete- if true, wait for the ES execution to be complete- Returns:
trueif the update was successful,falseotherwise
-
storeScripts
public boolean storeScripts(Map<String,String> scripts)
Description copied from interface:PersistenceServiceStore script in the Database for later usage with updateWithQueryAndStoredScript function for example.- Specified by:
storeScriptsin interfacePersistenceService- Parameters:
scripts- inline scripts map indexed by id- Returns:
trueif the update was successful,falseotherwise
-
updateWithScript
public boolean updateWithScript(Item item, Date dateHint, Class<?> clazz, String script, Map<String,Object> scriptParams)
- Specified by:
updateWithScriptin interfacePersistenceService
-
updateWithScript
public boolean updateWithScript(Item item, Class<?> clazz, String script, Map<String,Object> scriptParams)
Description copied from interface:PersistenceServiceUpdates the item of the specified class and identified by the specified identifier with a new property value for the specified property name. Same asupdate(itemId, clazz, Collections.singletonMap(propertyName, propertyValue))- Specified by:
updateWithScriptin interfacePersistenceService- Parameters:
item- the item we want to updateclazz- the Item subclass of the item to updatescript- inline scriptscriptParams- script params- Returns:
trueif the update was successful,falseotherwise
-
remove
public <T extends Item> boolean remove(String itemId, Class<T> clazz)
Description copied from interface:PersistenceServiceDeletes the item identified with the specified identifier and with the specified Item subclass if it exists.- Specified by:
removein interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to delete- Parameters:
itemId- the identifier of the item we want to deleteclazz- theItemsubclass of the item we want to delete- Returns:
trueif the deletion was successful,falseotherwise
-
removeCustomItem
public boolean removeCustomItem(String itemId, String customItemType)
Description copied from interface:PersistenceServiceRemove a custom item identified by the custom item identifier and the custom item type identifier- Specified by:
removeCustomItemin interfacePersistenceService- Parameters:
itemId- the identifier of the custom item to be removedcustomItemType- the name of the custom item type- Returns:
trueif the deletion was successful,falseotherwise
-
removeByQuery
public <T extends Item> boolean removeByQuery(Condition query, Class<T> clazz)
Description copied from interface:PersistenceServiceDeletes items with the specified Item subclass matching the specifiedCondition.- Specified by:
removeByQueryin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to delete- Parameters:
query- aConditionidentifying which elements we want to deleteclazz- theItemsubclass of the items we want to delete- Returns:
trueif the deletion was successful,falseotherwise
-
removeByQuery
public <T extends Item> boolean removeByQuery(org.elasticsearch.index.query.QueryBuilder queryBuilder, Class<T> clazz) throws Exception
- Throws:
Exception
-
indexTemplateExists
public boolean indexTemplateExists(String templateName)
-
removeIndexTemplate
public boolean removeIndexTemplate(String templateName)
-
registerRolloverLifecyclePolicy
public boolean registerRolloverLifecyclePolicy()
-
createIndex
public boolean createIndex(String itemType)
Description copied from interface:PersistenceServiceCreates an index with for the specified item type in the persistence engine.TODO: remove from API?
- Specified by:
createIndexin interfacePersistenceService- Parameters:
itemType- the item type- Returns:
trueif the operation was successful,falseotherwise
-
removeIndex
public boolean removeIndex(String itemType)
Description copied from interface:PersistenceServiceRemoves the index for the specified item type.TODO: remove from API?
- Specified by:
removeIndexin interfacePersistenceService- Parameters:
itemType- the item type- Returns:
trueif the operation was successful,falseotherwise
-
createMapping
public void createMapping(String type, String source)
Description copied from interface:PersistenceServiceCreate mapping- Specified by:
createMappingin interfacePersistenceService- Parameters:
type- the typesource- the source
-
setPropertyMapping
public void setPropertyMapping(PropertyType property, String itemType)
Description copied from interface:PersistenceServiceCreate the persistence mapping for specific property for a given type.- Specified by:
setPropertyMappingin interfacePersistenceService- Parameters:
property- the PropertyType to create mapping foritemType- the itemType we want to retrieve the mappings for
-
getPropertiesMapping
public Map<String,Map<String,Object>> getPropertiesMapping(String itemType)
Description copied from interface:PersistenceServiceRetrieve the type mappings for a given itemType. This method queries the persistence service implementation to retrieve any type mappings it may have for the specified itemType.This method may not return any results if the implementation doesn't support property type mappings
- Specified by:
getPropertiesMappingin interfacePersistenceService- Parameters:
itemType- the itemType we want to retrieve the mappings for- Returns:
- properties mapping
-
getPropertyMapping
public Map<String,Object> getPropertyMapping(String property, String itemType)
Description copied from interface:PersistenceServiceRetrieve the mapping for one specific property for a given type.- Specified by:
getPropertyMappingin interfacePersistenceService- Parameters:
property- the property name (can use nested dot notation)itemType- the itemType we want to retrieve the mappings for- Returns:
- property mapping
-
saveQuery
public boolean saveQuery(String queryName, Condition query)
Description copied from interface:PersistenceServicePersists the specified query under the specified name.- Specified by:
saveQueryin interfacePersistenceService- Parameters:
queryName- the name under which the specified query should be recordedquery- the query to be recorded- Returns:
trueif the query was properly saved,falseotherwise
-
removeQuery
public boolean removeQuery(String queryName)
Description copied from interface:PersistenceServiceDeletes the query identified by the specified name.- Specified by:
removeQueryin interfacePersistenceService- Parameters:
queryName- the name under which the specified query was recorded- Returns:
trueif the deletion was successful,falseotherwise
-
isValidCondition
public boolean isValidCondition(Condition condition, Item item)
Description copied from interface:PersistenceServicevalidates if a condition throws exception at query build.- Specified by:
isValidConditionin interfacePersistenceService- Parameters:
condition- the condition we're testing the specified item againstitem- the item we're checking against the specified condition- Returns:
trueif the item satisfies the condition,falseotherwise
-
testMatch
public boolean testMatch(Condition query, Item item)
Description copied from interface:PersistenceServiceChecks whether the specified item satisfies the provided condition.TODO: rename to isMatching?
- Specified by:
testMatchin interfacePersistenceService- Parameters:
query- the condition we're testing the specified item againstitem- the item we're checking against the specified condition- Returns:
trueif the item satisfies the condition,falseotherwise
-
query
public <T extends Item> List<T> query(Condition query, String sortBy, Class<T> clazz)
Description copied from interface:PersistenceServiceSame asquery(query, sortBy, clazz, 0, -1).getList()- Specified by:
queryin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
query- theConditionthe items must satisfy to be retrievedsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieve- Returns:
- a
PartialListof items matching the specified criteria - See Also:
PersistenceService.query(Condition, String, Class, int, int)
-
query
public <T extends Item> PartialList<T> query(Condition query, String sortBy, Class<T> clazz, int offset, int size)
Description copied from interface:PersistenceServiceRetrieves a list of items satisfying the specifiedCondition, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.- Specified by:
queryin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
query- theConditionthe items must satisfy to be retrievedsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieveoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrieved- Returns:
- a
PartialListof items matching the specified criteria
-
query
public <T extends Item> PartialList<T> query(Condition query, String sortBy, Class<T> clazz, int offset, int size, String scrollTimeValidity)
Description copied from interface:PersistenceServiceRetrieves a list of items satisfying the specifiedCondition, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one. If a scroll identifier and time validity are specified, they will be used to perform a scrolling query, meaning that only partial results will be returned, but the scrolling can be continued.- Specified by:
queryin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
query- theConditionthe items must satisfy to be retrievedsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieveoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrieved. In the case of a scroll query this will be used as the scrolling window size.scrollTimeValidity- the time the scrolling query should stay valid. This must contain a time unit value such as the ones supported by ElasticSearch, such as the ones declared here : https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units- Returns:
- a
PartialListof items matching the specified criteria, with an scroll identifier and the scroll validity used if a scroll query was requested.
-
queryCustomItem
public PartialList<CustomItem> queryCustomItem(Condition query, String sortBy, String customItemType, int offset, int size, String scrollTimeValidity)
Description copied from interface:PersistenceServiceRetrieves a list of items satisfying the specifiedCondition, ordered according to the specifiedsortByString and paged: onlysizeof them are retrieved, starting with theoffset-th one. If a scroll identifier and time validity are specified, they will be used to perform a scrolling query, meaning that only partial results will be returned, but the scrolling can be continued.- Specified by:
queryCustomItemin interfacePersistenceService- Parameters:
query- theConditionthe items must satisfy to be retrievedsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.customItemType- the identifier of the custom item type we want to queryoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrieved. In the case of a scroll query this will be used as the scrolling window size.scrollTimeValidity- the time the scrolling query should stay valid. This must contain a time unit value such as the ones supported by ElasticSearch, such as the ones declared here : https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units- Returns:
- a
PartialListof items matching the specified criteria, with an scroll identifier and the scroll validity used if a scroll query was requested.
-
queryFullText
public <T extends Item> PartialList<T> queryFullText(String fulltext, Condition query, String sortBy, Class<T> clazz, int offset, int size)
Description copied from interface:PersistenceServiceRetrieves the same items asquery(query, sortBy, clazz, 0, -1)with the added constraints that the matching elements must also have at least a field matching the specified full text query.- Specified by:
queryFullTextin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
fulltext- the text that the item must have in one of its fields to be considered a matchquery- theConditionthe items must satisfy to be retrievedsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieveoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrieved- Returns:
- a
PartialListof items matching the specified criteria
-
query
public <T extends Item> List<T> query(String fieldName, String fieldValue, String sortBy, Class<T> clazz)
Description copied from interface:PersistenceServiceSame asquery(fieldName, fieldValue, sortBy, clazz, 0, -1).getList()- Specified by:
queryin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
fieldName- the name of the field which we want items to have the specified valuesfieldValue- the value the items to retrieve should have for the specified fieldsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieve- Returns:
- a list of items matching the specified criteria
- See Also:
PersistenceService.query(Condition, String, Class, int, int)
-
query
public <T extends Item> List<T> query(String fieldName, String[] fieldValues, String sortBy, Class<T> clazz)
Description copied from interface:PersistenceServiceRetrieves a list of items with the specified field having the specified values.- Specified by:
queryin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
fieldName- the name of the field which we want items to have the specified valuesfieldValues- the values the items to retrieve should have for the specified fieldsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieve- Returns:
- a list of items matching the specified criteria
-
query
public <T extends Item> PartialList<T> query(String fieldName, String fieldValue, String sortBy, Class<T> clazz, int offset, int size)
Description copied from interface:PersistenceServiceRetrieves a list of items with the specified field having the specified value.- Specified by:
queryin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
fieldName- the name of the field which we want items to have the specified valuefieldValue- the value the items to retrieve should have for the specified fieldsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieveoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrieved- Returns:
- a
PartialListof items matching the specified criteria
-
queryFullText
public <T extends Item> PartialList<T> queryFullText(String fieldName, String fieldValue, String fulltext, String sortBy, Class<T> clazz, int offset, int size)
Description copied from interface:PersistenceServiceRetrieves a list of items with the specified field having the specified value and having at least a field with the specified full text value in it, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.- Specified by:
queryFullTextin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
fieldName- the name of the field which we want items to have the specified valuefieldValue- the value the items to retrieve should have for the specified fieldfulltext- the text that the item must have in one of its fields to be considered a matchsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieveoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrieved- Returns:
- a
PartialListof items matching the specified criteria
-
queryFullText
public <T extends Item> PartialList<T> queryFullText(String fulltext, String sortBy, Class<T> clazz, int offset, int size)
Description copied from interface:PersistenceServiceRetrieves a list of items having at least a field with the specified full text value in it, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.- Specified by:
queryFullTextin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
fulltext- the text that the item must have in one of its fields to be considered a matchsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieveoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrieved- Returns:
- a
PartialListof items matching the specified criteria
-
rangeQuery
public <T extends Item> PartialList<T> rangeQuery(String fieldName, String from, String to, String sortBy, Class<T> clazz, int offset, int size)
Description copied from interface:PersistenceServiceRetrieves all items of the specified Item subclass which specified ranged property is within the specified bounds, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.- Specified by:
rangeQueryin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
fieldName- the name of the range property we want items to retrieve to be included between the specified start and end pointsfrom- the beginning of the range we want to considerto- the end of the range we want to considersortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.clazz- theItemsubclass of the items we want to retrieveoffset- zero or a positive integer specifying the position of the first item in the total ordered collection of matching itemssize- a positive integer specifying how many matching items should be retrieved or-1if all of them should be retrieved- Returns:
- a
PartialListof items matching the specified criteria
-
queryCount
public long queryCount(Condition query, String itemType)
Description copied from interface:PersistenceServiceRetrieves the number of items of the specified type as defined by the Item subclass public fieldITEM_TYPEand matching the specifiedCondition.- Specified by:
queryCountin interfacePersistenceService- Parameters:
query- the condition the items must satisfyitemType- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPEfield- Returns:
- the number of items of the specified type
- See Also:
Item for a discussion of
-
continueScrollQuery
public <T extends Item> PartialList<T> continueScrollQuery(Class<T> clazz, String scrollIdentifier, String scrollTimeValidity)
Description copied from interface:PersistenceServiceContinues the execution of a scroll query, to retrieve the next results. If there are no more results the scroll query is also cleared.- Specified by:
continueScrollQueryin interfacePersistenceService- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
clazz- theItemsubclass of the items we want to retrievescrollIdentifier- a scroll identifier obtained by the execution of a first query and returned in thePartialListobjectscrollTimeValidity- a scroll time validity value for the scroll query to stay valid. This must contain a time unit value such as the ones supported by ElasticSearch, such as the ones declared here : https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units- Returns:
- a
PartialListof items matching the specified criteria, with an scroll identifier and the scroll validity used if a scroll query was requested. Note that if there are no more results the list will be empty but not null.
-
continueCustomItemScrollQuery
public PartialList<CustomItem> continueCustomItemScrollQuery(String customItemType, String scrollIdentifier, String scrollTimeValidity)
Description copied from interface:PersistenceServiceContinues the execution of a scroll query, to retrieve the next results. If there are no more results the scroll query is also cleared.- Specified by:
continueCustomItemScrollQueryin interfacePersistenceService- Parameters:
customItemType- the identifier of the custom item type we want to continue queryingscrollIdentifier- a scroll identifier obtained by the execution of a first query and returned in thePartialListobjectscrollTimeValidity- a scroll time validity value for the scroll query to stay valid. This must contain a time unit value such as the ones supported by ElasticSearch, such as the ones declared here : https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units- Returns:
- a
PartialListof items matching the specified criteria, with an scroll identifier and the scroll validity used if a scroll query was requested. Note that if there are no more results the list will be empty but not null.
-
aggregateQuery
@Deprecated public Map<String,Long> aggregateQuery(Condition filter, BaseAggregate aggregate, String itemType)
Deprecated.As of version 1.3.0-incubating, useaggregateWithOptimizedQuery(Condition, BaseAggregate, String)insteadDescription copied from interface:PersistenceServiceRetrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPEmatching the optional specified condition and aggregated according to the specifiedBaseAggregate. Also return the global count of document matching theITEM_TYPE- Specified by:
aggregateQueryin interfacePersistenceService- Parameters:
filter- the condition the items must match ornullif no filtering is neededaggregate- an aggregate specifying how matching items must be bundleditemType- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPEfield- Returns:
- a Map associating aggregation dimension name as key and cardinality for that dimension as value
-
aggregateWithOptimizedQuery
public Map<String,Long> aggregateWithOptimizedQuery(Condition filter, BaseAggregate aggregate, String itemType)
Description copied from interface:PersistenceServiceRetrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPEmatching the optional specified condition and aggregated according to the specifiedBaseAggregate. This aggregate won't return the global count and should therefore be much faster thanPersistenceService.aggregateQuery(Condition, BaseAggregate, String)- Specified by:
aggregateWithOptimizedQueryin interfacePersistenceService- Parameters:
filter- the condition the items must match ornullif no filtering is neededaggregate- an aggregate specifying how matching items must be bundleditemType- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPEfield- Returns:
- a Map associating aggregation dimension name as key and cardinality for that dimension as value
-
aggregateWithOptimizedQuery
public Map<String,Long> aggregateWithOptimizedQuery(Condition filter, BaseAggregate aggregate, String itemType, int size)
Description copied from interface:PersistenceServiceRetrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPEmatching the optional specified condition and aggregated according to the specifiedBaseAggregate.- Specified by:
aggregateWithOptimizedQueryin interfacePersistenceService- Parameters:
filter- the condition the items must match ornullif no filtering is neededaggregate- an aggregate specifying how matching items must be bundleditemType- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPEfieldsize- size of returned buckets in the response- Returns:
- a Map associating aggregation dimension name as key and cardinality for that dimension as value
-
refresh
public void refresh()
Description copied from interface:PersistenceServiceUpdates the persistence's engine indices if needed.- Specified by:
refreshin interfacePersistenceService
-
refreshIndex
public <T extends Item> void refreshIndex(Class<T> clazz, Date dateHint)
- Specified by:
refreshIndexin interfacePersistenceService
-
purge
public void purge(Date date)
Description copied from interface:PersistenceServicedeprecated: (use: purgeTimeBasedItems instead)- Specified by:
purgein interfacePersistenceService
-
purgeTimeBasedItems
public <T extends Item> void purgeTimeBasedItems(int existsNumberOfDays, Class<T> clazz)
Description copied from interface:PersistenceServicePurges time based data in the context server up to the specified days number of existence. (This only works for time based data stored in rolling over indices, it have no effect on other types)- Specified by:
purgeTimeBasedItemsin interfacePersistenceService- Parameters:
existsNumberOfDays- the number of daysclazz- the item type to be purged
-
purge
public void purge(String scope)
Description copied from interface:PersistenceServiceRemoves all data associated with the provided scope.- Specified by:
purgein interfacePersistenceService- Parameters:
scope- the scope for which we want to remove data
-
getSingleValuesMetrics
public Map<String,Double> getSingleValuesMetrics(Condition condition, String[] metrics, String field, String itemType)
Description copied from interface:PersistenceServiceRetrieves the specified metrics for the specified field of items of the specified type as defined by the Item subclass public fieldITEM_TYPEand matching the specifiedCondition.- Specified by:
getSingleValuesMetricsin interfacePersistenceService- Parameters:
condition- the condition the items must satisfymetrics- a String array which metrics should be computed (possible values:sumfor the sum of the values,avgfor the average of the values,minfor the minimum value andmaxfor the maximum value)field- the name of the field for which the metrics should be computeditemType- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPEfield- Returns:
- a Map associating computed metric name as key to its associated value
-
-