Package org.apache.unomi.persistence.spi
Interface PersistenceService
- All Known Implementing Classes:
ElasticSearchPersistenceServiceImpl
public interface PersistenceService
A service to provide persistence and retrieval of context server entities.
-
Method Summary
Modifier and TypeMethodDescriptionaggregateQuery(Condition filter, BaseAggregate aggregate, String itemType) Deprecated.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.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.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 mappinggetAllItems(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.getPropertiesMapping(String itemType) Retrieve the type mappings for a given itemType.getPropertyMapping(String property, String itemType) Retrieve the mapping for one specific property for a given type.getSingleValuesMetrics(Condition condition, String[] metrics, String field, String type) 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.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>
TRetrieves the item identified with the specified identifier and with the specified Item subclass if it exists.<T extends Item>
TDeprecated.default 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 typeloadCustomItem(String itemId, Date dateHint, String customItemType) Deprecated.voidRemoves all data associated with the provided scope.voidDeprecated.<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.Retrieves a list of items with the specified field having the specified values.Same asquery(fieldName, fieldValue, sortBy, clazz, 0, -1).getList()<T extends Item>
PartialList<T>Retrieves a list of items with the specified field having the specified value.Same asquery(query, sortBy, clazz, 0, -1).getList()<T extends Item>
PartialList<T>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.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>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.default <T extends Item>
voidrefreshIndex(Class<T> clazz) Updates the persistence's engine specific index.<T extends Item>
voidrefreshIndex(Class<T> clazz, Date dateHint) Deprecated.<T extends Item>
booleanDeletes 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.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.booleanremoveQuery(String queryName) Deletes the query identified by the specified name.booleanPersists the specified Item in the context server.booleanPersists the specified Item in the context server.booleanPersists the specified Item in the context server.booleanPersists the specified query under the specified name.voidsetPropertyMapping(PropertyType property, String itemType) Create the persistence mapping for specific property for a given type.booleanstoreScripts(Map<String, String> scripts) Store script in the Database for later usage with updateWithQueryAndStoredScript function for example.booleanChecks whether the specified item satisfies the provided condition.Updates Map of items of the specified class and identified by the specified identifier with a new property value for the specified property name.Deprecated.default booleanUpdates the item of the specified class and identified by the specified identifier with a new property value for the specified property name.default booleanUpdates 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.default booleanUpdates 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.booleanDeprecated.booleanDeprecated.booleanDeprecated.default 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) Deprecated.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.default 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) default booleanUpdates 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) Deprecated.
-
Method Details
-
getAllItems
Retrieves all known items of the specified class. WARNING: this method can be quite computationally intensive and calling the paged versiongetAllItems(Class, int, int, String)is preferred. -
getAllItems
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.TODO: use a Query object instead of distinct parameters?
- 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
<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.TODO: use a Query object instead of distinct parameters?
- 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
-
isConsistent
Return true if the item which is saved in the persistence service is consistent- Parameters:
item- the item to the check if consistent- Returns:
trueif the item is consistent, false otherwise
-
save
Persists the specified Item in the context server.- Parameters:
item- the item to persist- Returns:
trueif the item was properly persisted,falseotherwise
-
save
Persists the specified Item in the context server.- 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
Persists the specified Item in the context server.- 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 backendalwaysOverwrite- whether to overwrite a document even if we are holding an old item when saving- Returns:
trueif the item was properly persisted,falseotherwise
-
update
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.- 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
Deprecated. -
update
Updates 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))- 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
@Deprecated boolean update(Item item, Date dateHint, Class<?> clazz, String propertyName, Object propertyValue) Deprecated. -
update
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.- 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
@Deprecated boolean update(Item item, Date dateHint, Class<?> clazz, Map<?, ?> source, boolean alwaysOverwrite) Deprecated. -
update
Updates Map of items 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))- Parameters:
items- A map the consist of item (key) and properties to update (value)clazz- the Item subclass of the item to update- Returns:
- List of failed Items Ids, if all succesful then returns an empty list. if the whole operation failed then will return null
-
update
Deprecated. -
updateWithScript
default boolean updateWithScript(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. Same asupdate(itemId, clazz, Collections.singletonMap(propertyName, propertyValue))- 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
-
updateWithScript
@Deprecated boolean updateWithScript(Item item, Date dateHint, Class<?> clazz, String script, Map<String, Object> scriptParams) Deprecated. -
updateWithQueryAndScript
default boolean updateWithQueryAndScript(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 parameters- 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
-
updateWithQueryAndScript
@Deprecated boolean updateWithQueryAndScript(Date dateHint, Class<?> clazz, String[] scripts, Map<String, Object>[] scriptParams, Condition[] conditions) Deprecated. -
updateWithQueryAndStoredScript
default boolean updateWithQueryAndStoredScript(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 parameters- 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
boolean updateWithQueryAndStoredScript(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.- 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
-
updateWithQueryAndStoredScript
-
storeScripts
Store script in the Database for later usage with updateWithQueryAndStoredScript function for example.- Parameters:
scripts- inline scripts map indexed by id- Returns:
trueif the update was successful,falseotherwise
-
load
Retrieves the item identified with the specified identifier and with the specified Item subclass if it exists.- 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. -
loadCustomItem
Load a custom item type identified by an identifier, an optional date hint and the identifier of the custom item type- 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
-
loadCustomItem
Deprecated. -
remove
Deletes the item identified with the specified identifier and with the specified Item subclass if it exists.- 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
Remove a custom item identified by the custom item identifier and the custom item type identifier- 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
Deletes items with the specified Item subclass matching the specifiedCondition. -
saveQuery
Persists the specified query under the specified name.- 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
Deletes the query identified by the specified name.- Parameters:
queryName- the name under which the specified query was recorded- Returns:
trueif the deletion was successful,falseotherwise
-
getPropertiesMapping
Retrieve 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
- Parameters:
itemType- the itemType we want to retrieve the mappings for- Returns:
- properties mapping
-
getPropertyMapping
Retrieve the mapping for one specific property for a given type.- Parameters:
property- the property name (can use nested dot notation)itemType- the itemType we want to retrieve the mappings for- Returns:
- property mapping
-
setPropertyMapping
Create the persistence mapping for specific property for a given type.- Parameters:
property- the PropertyType to create mapping foritemType- the itemType we want to retrieve the mappings for
-
createMapping
Create mapping- Parameters:
type- the typesource- the source
-
testMatch
Checks whether the specified item satisfies the provided condition.TODO: rename to isMatching?
- 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
-
isValidCondition
validates if a condition throws exception at query build.- 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
-
query
Same asquery(fieldName, fieldValue, sortBy, clazz, 0, -1).getList()- 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:
-
query
<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.- 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
<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.- 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
<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.- 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
<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.- 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
-
query
Same asquery(query, sortBy, clazz, 0, -1).getList()- 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:
-
query
<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.- 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
<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. 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.- 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.
-
continueScrollQuery
<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. If there are no more results the scroll query is also cleared.- 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.
-
queryCustomItem
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. 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.- 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.
-
continueCustomItemScrollQuery
PartialList<CustomItem> continueCustomItemScrollQuery(String customItemType, String scrollIdentifier, String scrollTimeValidity) Continues the execution of a scroll query, to retrieve the next results. If there are no more results the scroll query is also cleared.- 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.
-
queryFullText
<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.- 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
-
queryCount
Retrieves the number of items of the specified type as defined by the Item subclass public fieldITEM_TYPEand matching the specifiedCondition.- 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:
-
getAllItemsCount
Retrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPE.- 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:
-
aggregateQuery
@Deprecated Map<String,Long> aggregateQuery(Condition filter, BaseAggregate aggregate, String itemType) Deprecated.As of 1.3.0-incubating, please useaggregateWithOptimizedQuery(Condition, BaseAggregate, String)insteadRetrieves 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- 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
Map<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. This aggregate won't return the global count and should therefore be much faster thanaggregateQuery(Condition, BaseAggregate, String)- 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
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.- 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
void refresh()Updates the persistence's engine indices if needed. -
refreshIndex
Updates the persistence's engine specific index.- Type Parameters:
T- a class that extends Item- Parameters:
clazz- will use an index by class type
-
refreshIndex
Deprecated. -
purge
Deprecated.deprecated: (use: purgeTimeBasedItems instead) -
purgeTimeBasedItems
Purges 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)- Parameters:
existsNumberOfDays- the number of daysclazz- the item type to be purged
-
rangeQuery
<T extends Item> PartialList<T> rangeQuery(String s, 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.- Type Parameters:
T- the type of the Item subclass we want to retrieve- Parameters:
s- 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
-
getSingleValuesMetrics
Map<String,Double> getSingleValuesMetrics(Condition condition, String[] metrics, String field, String type) 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.- 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 computedtype- 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
-
createIndex
Creates an index with for the specified item type in the persistence engine.TODO: remove from API?
- Parameters:
itemType- the item type- Returns:
trueif the operation was successful,falseotherwise
-
removeIndex
Removes the index for the specified item type.TODO: remove from API?
- Parameters:
itemType- the item type- Returns:
trueif the operation was successful,falseotherwise
-
purge
Removes all data associated with the provided scope.- Parameters:
scope- the scope for which we want to remove data
-
aggregateWithOptimizedQuery(Condition, BaseAggregate, String)instead