public interface PersistenceService
Modifier and Type | Method and Description |
---|---|
Map<String,Long> |
aggregateQuery(Condition filter,
BaseAggregate aggregate,
String itemType)
Deprecated.
As of 1.3.0-incubating, please use
aggregateWithOptimizedQuery(Condition, BaseAggregate, String) instead |
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 field
ITEM_TYPE matching the optional specified condition and
aggregated according to the specified BaseAggregate . |
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 field
ITEM_TYPE matching the optional specified condition and
aggregated according to the specified BaseAggregate . |
PartialList<CustomItem> |
continueCustomItemScrollQuery(String customItemType,
String scrollIdentifier,
String scrollTimeValidity)
Continues the execution of a scroll query, to retrieve the next results.
|
<T extends Item> |
continueScrollQuery(Class<T> clazz,
String scrollIdentifier,
String scrollTimeValidity)
Continues the execution of a scroll query, to retrieve the next results.
|
boolean |
createIndex(String itemType)
Creates an index with for the specified item type in the persistence engine.
|
void |
createMapping(String type,
String source)
Create mapping
|
<T extends Item> |
getAllItems(Class<T> clazz)
Retrieves all known items of the specified class.
|
<T extends Item> |
getAllItems(Class<T> clazz,
int offset,
int size,
String sortBy)
Retrieves all known items of the specified class, ordered according to the specified
sortBy String and and paged: only size of them are retrieved,
starting with the offset -th one. |
<T extends Item> |
getAllItems(Class<T> clazz,
int offset,
int size,
String sortBy,
String scrollTimeValidity)
Retrieves all known items of the specified class, ordered according to the specified
sortBy String and and paged: only size of them are retrieved,
starting with the offset -th one. |
long |
getAllItemsCount(String itemType)
Retrieves the number of items with the specified type as defined by the Item subclass public field
ITEM_TYPE . |
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 type)
Retrieves the specified metrics for the specified field of items of the specified type as defined by the Item subclass public field
ITEM_TYPE and matching the
specified Condition . |
boolean |
isConsistent(Item item)
Return true if the item which is saved in the persistence service is consistent
|
boolean |
isValidCondition(Condition condition,
Item item)
validates if a condition throws exception at query build.
|
<T extends Item> |
load(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> |
load(String itemId,
Date dateHint,
Class<T> clazz)
Deprecated.
|
CustomItem |
loadCustomItem(String itemId,
Date dateHint,
String customItemType)
Deprecated.
|
default CustomItem |
loadCustomItem(String itemId,
String customItemType)
Load a custom item type identified by an identifier, an optional date hint and the identifier of the custom item type
|
void |
purge(Date date)
Deprecated.
|
void |
purge(String scope)
Removes all data associated with the provided scope.
|
<T extends Item> |
purgeTimeBasedItems(int existsNumberOfDays,
Class<T> clazz)
Purges time based data in the context server up to the specified days number of existence.
|
<T extends Item> |
query(Condition query,
String sortBy,
Class<T> clazz)
Same as
query(query, sortBy, clazz, 0, -1).getList() |
<T extends Item> |
query(Condition query,
String sortBy,
Class<T> clazz,
int offset,
int size)
Retrieves a list of items satisfying the specified
Condition , ordered according to the specified sortBy String and and paged: only size of them
are retrieved, starting with the offset -th one. |
<T extends Item> |
query(Condition query,
String sortBy,
Class<T> clazz,
int offset,
int size,
String scrollTimeValidity)
Retrieves a list of items satisfying the specified
Condition , ordered according to the specified sortBy String and and paged: only size of them
are retrieved, starting with the offset -th one. |
<T extends Item> |
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> |
query(String fieldName,
String fieldValue,
String sortBy,
Class<T> clazz)
Same as
query(fieldName, fieldValue, sortBy, clazz, 0, -1).getList() |
<T extends Item> |
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.
|
long |
queryCount(Condition query,
String itemType)
Retrieves the number of items of the specified type as defined by the Item subclass public field
ITEM_TYPE and matching the specified Condition . |
PartialList<CustomItem> |
queryCustomItem(Condition query,
String sortBy,
String customItemType,
int offset,
int size,
String scrollTimeValidity)
Retrieves a list of items satisfying the specified
Condition , ordered according to the specified
sortBy String and paged: only size of them are retrieved, starting with the
offset -th one. |
<T extends Item> |
queryFullText(String fulltext,
Condition query,
String sortBy,
Class<T> clazz,
int offset,
int size)
Retrieves the same items as
query(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> |
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 specified
sortBy String and and paged: only
size of them are retrieved, starting with the offset -th one. |
<T extends Item> |
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
specified
sortBy String and and paged: only size of them are retrieved, starting with the offset -th one. |
<T extends Item> |
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 specified
sortBy String
and and paged: only size of them are retrieved, starting with the offset -th one. |
void |
refresh()
Updates the persistence's engine indices if needed.
|
default <T extends Item> |
refreshIndex(Class<T> clazz)
Updates the persistence's engine specific index.
|
<T extends Item> |
refreshIndex(Class<T> clazz,
Date dateHint)
Deprecated.
|
<T extends Item> |
remove(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> |
removeByQuery(Condition query,
Class<T> clazz)
Deletes items with the specified Item subclass matching the specified
Condition . |
boolean |
removeCustomItem(String itemId,
String customItemType)
Remove a custom item identified by the custom item identifier and the custom item type identifier
|
boolean |
removeIndex(String itemType)
Removes the index for the specified item type.
|
boolean |
removeQuery(String queryName)
Deletes the query identified by the specified name.
|
boolean |
save(Item item)
Persists the specified Item in the context server.
|
boolean |
save(Item item,
boolean useBatching)
Persists the specified Item in the context server.
|
boolean |
save(Item item,
Boolean useBatching,
Boolean alwaysOverwrite)
Persists the specified Item in the context server.
|
boolean |
saveQuery(String queryName,
Condition query)
Persists the specified query under the specified name.
|
void |
setPropertyMapping(PropertyType property,
String itemType)
Create the persistence mapping for specific property for a given type.
|
boolean |
storeScripts(Map<String,String> scripts)
Store script in the Database for later usage with updateWithQueryAndStoredScript function for example.
|
boolean |
testMatch(Condition query,
Item item)
Checks whether the specified item satisfies the provided condition.
|
default boolean |
update(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.
|
default boolean |
update(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.
|
default boolean |
update(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.
|
boolean |
update(Item item,
Date dateHint,
Class<?> clazz,
Map<?,?> source)
Deprecated.
|
boolean |
update(Item item,
Date dateHint,
Class<?> clazz,
Map<?,?> source,
boolean alwaysOverwrite)
Deprecated.
|
boolean |
update(Item item,
Date dateHint,
Class<?> clazz,
String propertyName,
Object propertyValue)
Deprecated.
|
default List<String> |
update(Map<Item,Map> items,
Class clazz)
Updates Map of items of the specified class and identified by the specified identifier with a new property value for the specified property name.
|
List<String> |
update(Map<Item,Map> items,
Date dateHint,
Class clazz)
Deprecated.
|
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
|
boolean |
updateWithQueryAndScript(Date dateHint,
Class<?> clazz,
String[] scripts,
Map<String,Object>[] scriptParams,
Condition[] conditions)
Deprecated.
|
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
|
boolean |
updateWithQueryAndStoredScript(Date dateHint,
Class<?> clazz,
String[] scripts,
Map<String,Object>[] scriptParams,
Condition[] conditions)
|
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.
|
boolean |
updateWithScript(Item item,
Date dateHint,
Class<?> clazz,
String script,
Map<String,Object> scriptParams)
Deprecated.
|
<T extends Item> List<T> getAllItems(Class<T> clazz)
getAllItems(Class, int, int, String)
is preferred.<T extends Item> PartialList<T> getAllItems(Class<T> clazz, int offset, int size, String sortBy)
sortBy
String and and paged: only size
of them are retrieved,
starting with the offset
-th one.
TODO: use a Query object instead of distinct parameters?
T
- the type of the Item
s we want to retrieveclazz
- the Item
subclass 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 -1
if all of them should be retrievedsortBy
- an optional (null
if 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: asc
or desc
.PartialList
of pages items with the given type<T extends Item> PartialList<T> getAllItems(Class<T> clazz, int offset, int size, String sortBy, String scrollTimeValidity)
sortBy
String and and paged: only size
of them are retrieved,
starting with the offset
-th one.
TODO: use a Query object instead of distinct parameters?
T
- the type of the Item
s we want to retrieveclazz
- the Item
subclass 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 -1
if all of them should be retrievedsortBy
- an optional (null
if 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: asc
or desc
.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-unitsPartialList
of pages items with the given typeboolean isConsistent(Item item)
item
- the item to the check if consistenttrue
if the item is consistent, false otherwiseboolean save(Item item)
item
- the item to persisttrue
if the item was properly persisted, false
otherwiseboolean save(Item item, boolean useBatching)
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.true
if the item was properly persisted, false
otherwiseboolean save(Item item, Boolean useBatching, Boolean alwaysOverwrite)
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 savingtrue
if the item was properly persisted, false
otherwisedefault boolean update(Item item, Class<?> clazz, Map<?,?> source)
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 valuetrue
if the update was successful, false
otherwise@Deprecated boolean update(Item item, Date dateHint, Class<?> clazz, Map<?,?> source)
update(Item, Class, Map)
default boolean update(Item item, Class<?> clazz, String propertyName, Object propertyValue)
update(itemId, clazz, Collections.singletonMap(propertyName, propertyValue))
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 propertytrue
if the update was successful, false
otherwise@Deprecated boolean update(Item item, Date dateHint, Class<?> clazz, String propertyName, Object propertyValue)
update(Item, Class, String, Object)
default boolean update(Item item, Class<?> clazz, Map<?,?> source, boolean alwaysOverwrite)
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 savingtrue
if the update was successful, false
otherwise@Deprecated boolean update(Item item, Date dateHint, Class<?> clazz, Map<?,?> source, boolean alwaysOverwrite)
update(Item, Class, Map, boolean)
default List<String> update(Map<Item,Map> items, Class clazz)
update(itemId, clazz, Collections.singletonMap(propertyName, propertyValue))
items
- A map the consist of item (key) and properties to update (value)clazz
- the Item subclass of the item to update@Deprecated List<String> update(Map<Item,Map> items, Date dateHint, Class clazz)
update(Map, Class)
default boolean updateWithScript(Item item, Class<?> clazz, String script, Map<String,Object> scriptParams)
update(itemId, clazz, Collections.singletonMap(propertyName, propertyValue))
item
- the item we want to updateclazz
- the Item subclass of the item to updatescript
- inline scriptscriptParams
- script paramstrue
if the update was successful, false
otherwise@Deprecated boolean updateWithScript(Item item, Date dateHint, Class<?> clazz, String script, Map<String,Object> scriptParams)
updateWithScript(Item, Class, String, Map)
default boolean updateWithQueryAndScript(Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)
clazz
- the Item subclass of the item to updatescripts
- inline scripts arrayscriptParams
- script params arrayconditions
- conditions arraytrue
if the update was successful, false
otherwise@Deprecated boolean updateWithQueryAndScript(Date dateHint, Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)
updateWithQueryAndScript(Class, String[], Map[], Condition[])
default boolean updateWithQueryAndStoredScript(Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)
clazz
- the Item subclass of the item to updatescripts
- Stored scripts namescriptParams
- script params arrayconditions
- conditions arraytrue
if the update was successful, false
otherwise@Deprecated boolean updateWithQueryAndStoredScript(Date dateHint, Class<?> clazz, String[] scripts, Map<String,Object>[] scriptParams, Condition[] conditions)
boolean storeScripts(Map<String,String> scripts)
scripts
- inline scripts map indexed by idtrue
if the update was successful, false
otherwise<T extends Item> T load(String itemId, Class<T> clazz)
T
- the type of the Item subclass we want to retrieveitemId
- the identifier of the item we want to retrieveclazz
- the Item
subclass of the item we want to retrievenull
otherwise@Deprecated <T extends Item> T load(String itemId, Date dateHint, Class<T> clazz)
load(String, Class)
default CustomItem loadCustomItem(String itemId, String customItemType)
itemId
- the identifier of the custom type we want to retrievecustomItemType
- an identifier of the custom item type to loadnull
otherwise@Deprecated CustomItem loadCustomItem(String itemId, Date dateHint, String customItemType)
loadCustomItem(String, String)
<T extends Item> boolean remove(String itemId, Class<T> clazz)
T
- the type of the Item subclass we want to deleteitemId
- the identifier of the item we want to deleteclazz
- the Item
subclass of the item we want to deletetrue
if the deletion was successful, false
otherwiseboolean removeCustomItem(String itemId, String customItemType)
itemId
- the identifier of the custom item to be removedcustomItemType
- the name of the custom item typetrue
if the deletion was successful, false
otherwise<T extends Item> boolean removeByQuery(Condition query, Class<T> clazz)
Condition
.boolean saveQuery(String queryName, Condition query)
queryName
- the name under which the specified query should be recordedquery
- the query to be recordedtrue
if the query was properly saved, false
otherwiseboolean removeQuery(String queryName)
queryName
- the name under which the specified query was recordedtrue
if the deletion was successful, false
otherwiseMap<String,Map<String,Object>> getPropertiesMapping(String itemType)
This method may not return any results if the implementation doesn't support property type mappings
itemType
- the itemType we want to retrieve the mappings forMap<String,Object> getPropertyMapping(String property, String itemType)
property
- the property name (can use nested dot notation)itemType
- the itemType we want to retrieve the mappings forvoid setPropertyMapping(PropertyType property, String itemType)
property
- the PropertyType to create mapping foritemType
- the itemType we want to retrieve the mappings forvoid createMapping(String type, String source)
type
- the typesource
- the sourceboolean testMatch(Condition query, Item item)
TODO: rename to isMatching?
query
- the condition we're testing the specified item againstitem
- the item we're checking against the specified conditiontrue
if the item satisfies the condition, false
otherwiseboolean isValidCondition(Condition condition, Item item)
condition
- the condition we're testing the specified item againstitem
- the item we're checking against the specified conditiontrue
if the item satisfies the condition, false
otherwise<T extends Item> List<T> query(String fieldName, String fieldValue, String sortBy, Class<T> clazz)
query(fieldName, fieldValue, sortBy, clazz, 0, -1).getList()
T
- the type of the Item subclass we want to retrievefieldName
- 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 (null
if 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: asc
or desc
.clazz
- the Item
subclass of the items we want to retrievequery(Condition, String, Class, int, int)
<T extends Item> List<T> query(String fieldName, String[] fieldValues, String sortBy, Class<T> clazz)
T
- the type of the Item subclass we want to retrievefieldName
- 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 (null
if 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: asc
or desc
.clazz
- the Item
subclass of the items we want to retrieve<T extends Item> PartialList<T> query(String fieldName, String fieldValue, String sortBy, Class<T> clazz, int offset, int size)
T
- the type of the Item subclass we want to retrievefieldName
- 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 (null
if 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: asc
or desc
.clazz
- the Item
subclass 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 -1
if all of them should be retrievedPartialList
of items matching the specified criteria<T extends Item> PartialList<T> queryFullText(String fieldName, String fieldValue, String fulltext, String sortBy, Class<T> clazz, int offset, int size)
sortBy
String and and paged: only size
of them are retrieved, starting with the offset
-th one.T
- the type of the Item subclass we want to retrievefieldName
- 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 (null
if 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: asc
or desc
.clazz
- the Item
subclass 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 -1
if all of them should be retrievedPartialList
of items matching the specified criteria<T extends Item> PartialList<T> queryFullText(String fulltext, String sortBy, Class<T> clazz, int offset, int size)
sortBy
String and and paged: only
size
of them are retrieved, starting with the offset
-th one.T
- the type of the Item subclass we want to retrievefulltext
- the text that the item must have in one of its fields to be considered a matchsortBy
- an optional (null
if 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: asc
or desc
.clazz
- the Item
subclass 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 -1
if all of them should be retrievedPartialList
of items matching the specified criteria<T extends Item> List<T> query(Condition query, String sortBy, Class<T> clazz)
query(query, sortBy, clazz, 0, -1).getList()
T
- the type of the Item subclass we want to retrievequery
- the Condition
the items must satisfy to be retrievedsortBy
- an optional (null
if 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: asc
or desc
.clazz
- the Item
subclass of the items we want to retrievePartialList
of items matching the specified criteriaquery(Condition, String, Class, int, int)
<T extends Item> PartialList<T> query(Condition query, String sortBy, Class<T> clazz, int offset, int size)
Condition
, ordered according to the specified sortBy
String and and paged: only size
of them
are retrieved, starting with the offset
-th one.T
- the type of the Item subclass we want to retrievequery
- the Condition
the items must satisfy to be retrievedsortBy
- an optional (null
if 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: asc
or desc
.clazz
- the Item
subclass 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 -1
if all of them should be retrievedPartialList
of items matching the specified criteria<T extends Item> PartialList<T> query(Condition query, String sortBy, Class<T> clazz, int offset, int size, String scrollTimeValidity)
Condition
, ordered according to the specified sortBy
String and and paged: only size
of them
are retrieved, starting with the offset
-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.T
- the type of the Item subclass we want to retrievequery
- the Condition
the items must satisfy to be retrievedsortBy
- an optional (null
if 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: asc
or desc
.clazz
- the Item
subclass 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 -1
if 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-unitsPartialList
of items matching the specified criteria, with an scroll identifier and the scroll validity used if a scroll query was requested.<T extends Item> PartialList<T> continueScrollQuery(Class<T> clazz, String scrollIdentifier, String scrollTimeValidity)
T
- the type of the Item subclass we want to retrieveclazz
- the Item
subclass of the items we want to retrievescrollIdentifier
- a scroll identifier obtained by the execution of a first query and returned in the PartialList
objectscrollTimeValidity
- 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-unitsPartialList
of 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.PartialList<CustomItem> queryCustomItem(Condition query, String sortBy, String customItemType, int offset, int size, String scrollTimeValidity)
Condition
, ordered according to the specified
sortBy
String and paged: only size
of them are retrieved, starting with the
offset
-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.query
- the Condition
the items must satisfy to be retrievedsortBy
- an optional (null
if 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: asc
or desc
.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 -1
if 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-unitsPartialList
of items matching the specified criteria, with an scroll identifier and the scroll validity used if a scroll query was requested.PartialList<CustomItem> continueCustomItemScrollQuery(String customItemType, String scrollIdentifier, String scrollTimeValidity)
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 the PartialList
objectscrollTimeValidity
- 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-unitsPartialList
of 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.<T extends Item> PartialList<T> queryFullText(String fulltext, Condition query, String sortBy, Class<T> clazz, int offset, int size)
query(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
- the type of the Item subclass we want to retrievefulltext
- the text that the item must have in one of its fields to be considered a matchquery
- the Condition
the items must satisfy to be retrievedsortBy
- an optional (null
if 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: asc
or desc
.clazz
- the Item
subclass 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 -1
if all of them should be retrievedPartialList
of items matching the specified criterialong queryCount(Condition query, String itemType)
ITEM_TYPE
and matching the specified Condition
.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_TYPE
fieldItem for a discussion of {@code ITEM_TYPE}
long getAllItemsCount(String itemType)
ITEM_TYPE
.itemType
- the String representation of the item type we want to retrieve the count of, as defined by its class' ITEM_TYPE
fieldItem for a discussion of {@code ITEM_TYPE}
@Deprecated Map<String,Long> aggregateQuery(Condition filter, BaseAggregate aggregate, String itemType)
aggregateWithOptimizedQuery(Condition, BaseAggregate, String)
insteadITEM_TYPE
matching the optional specified condition and
aggregated according to the specified BaseAggregate
.
Also return the global count of document matching the ITEM_TYPE
filter
- the condition the items must match or null
if 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_TYPE
fieldMap<String,Long> aggregateWithOptimizedQuery(Condition filter, BaseAggregate aggregate, String itemType)
ITEM_TYPE
matching the optional specified condition and
aggregated according to the specified BaseAggregate
.
This aggregate won't return the global count and should therefore be much faster than aggregateQuery(Condition, BaseAggregate, String)
filter
- the condition the items must match or null
if 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_TYPE
fieldMap<String,Long> aggregateWithOptimizedQuery(Condition filter, BaseAggregate aggregate, String itemType, int size)
ITEM_TYPE
matching the optional specified condition and
aggregated according to the specified BaseAggregate
.filter
- the condition the items must match or null
if 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_TYPE
fieldsize
- size of returned buckets in the responsevoid refresh()
default <T extends Item> void refreshIndex(Class<T> clazz)
T
- a class that extends Itemclazz
- will use an index by class type@Deprecated <T extends Item> void refreshIndex(Class<T> clazz, Date dateHint)
refreshIndex(Class)
@Deprecated void purge(Date date)
<T extends Item> void purgeTimeBasedItems(int existsNumberOfDays, Class<T> clazz)
existsNumberOfDays
- the number of daysclazz
- the item type to be purged<T extends Item> PartialList<T> rangeQuery(String s, String from, String to, String sortBy, Class<T> clazz, int offset, int size)
sortBy
String
and and paged: only size
of them are retrieved, starting with the offset
-th one.T
- the type of the Item subclass we want to retrieves
- 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 (null
if 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: asc
or desc
.clazz
- the Item
subclass 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 -1
if all of them should be retrievedPartialList
of items matching the specified criteriaMap<String,Double> getSingleValuesMetrics(Condition condition, String[] metrics, String field, String type)
ITEM_TYPE
and matching the
specified Condition
.condition
- the condition the items must satisfymetrics
- a String array which metrics should be computed (possible values: sum
for the sum of the values, avg
for the average of the values, min
for the minimum value and max
for 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_TYPE
fieldboolean createIndex(String itemType)
TODO: remove from API?
itemType
- the item typetrue
if the operation was successful, false
otherwiseboolean removeIndex(String itemType)
TODO: remove from API?
itemType
- the item typetrue
if the operation was successful, false
otherwisevoid purge(String scope)
scope
- the scope for which we want to remove dataCopyright © 2014–2023 Apache Software Foundation. All rights reserved.