Package org.apache.unomi.rest.endpoints
Class QueryServiceEndPoint
java.lang.Object
org.apache.unomi.rest.endpoints.QueryServiceEndPoint
@Produces("application/json")
@Consumes("application/json")
@Path("/query")
public class QueryServiceEndPoint
extends Object
A JAX-RS endpoint to perform queries against context-server data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAggregate
(String type, String property) Retrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPE
and aggregated by possible values of the specified property.getAggregate
(String type, String property, boolean optimizedQuery, AggregateQuery aggregateQuery) TODO: rework, this method is confusing since it either behaves likegetAggregate(String, String)
if query is null but completely differently if it isn't Retrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPE
and aggregated by possible values of the specified property or, if the specified query is notnull
, perform that aggregate query.Retrieves the specified metrics for the specified field of items of the specified type as defined by the Item subclass public fieldITEM_TYPE
and matching the specifiedCondition
.long
getQueryCount
(String type, Boolean validate, Condition condition, javax.servlet.http.HttpServletResponse response) Retrieves the number of items of the specified type as defined by the Item subclass public fieldITEM_TYPE
and matching the specifiedCondition
.void
setLocalizationHelper
(LocalizationHelper localizationHelper) void
setQueryService
(QueryService queryService)
-
Constructor Details
-
QueryServiceEndPoint
public QueryServiceEndPoint()
-
-
Method Details
-
setQueryService
-
setLocalizationHelper
-
getAggregate
@GET @Path("/{type}/{property}") public Map<String,Long> getAggregate(@PathParam("type") String type, @PathParam("property") String property) Retrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPE
and aggregated by possible values of the specified property.- Parameters:
type
- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPE
fieldproperty
- the property we're aggregating on, i.e. for each possible value of this property, we are counting how many items of the specified type have that value- Returns:
- a Map associating a specific value of the property to the cardinality of items with that value
- See Also:
-
getAggregate
@POST @Path("/{type}/{property}") public Map<String,Long> getAggregate(@PathParam("type") String type, @PathParam("property") String property, @QueryParam("optimizedQuery") boolean optimizedQuery, AggregateQuery aggregateQuery) TODO: rework, this method is confusing since it either behaves likegetAggregate(String, String)
if query is null but completely differently if it isn't Retrieves the number of items with the specified type as defined by the Item subclass public fieldITEM_TYPE
and aggregated by possible values of the specified property or, if the specified query is notnull
, perform that aggregate query. Also return the global count of document matching theITEM_TYPE
if you don't useoptimizedQuery
or set it to false, otherwise ifoptimizedQuery
is set to true then it won't return the global count but the query will be executed much faster.- Parameters:
type
- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPE
fieldproperty
- the property we're aggregating on, i.e. for each possible value of this property, we are counting how many items of the specified type have that valueaggregateQuery
- theAggregateQuery
specifying the aggregation that should be performedoptimizedQuery
- theoptimizedQuery
specifying if we should optimized the aggregate query or not- Returns:
- a Map associating a specific value of the property to the cardinality of items with that value
- See Also:
-
getMetric
@POST @Path("/{type}/{property}/{metricTypes:((sum|avg|min|max)/?)*}") public Map<String,Double> getMetric(@PathParam("type") String type, @PathParam("property") String property, @PathParam("metricTypes") String metricsType, Condition condition) Retrieves the specified metrics for the specified field of items of the specified type as defined by the Item subclass public fieldITEM_TYPE
and matching the specifiedCondition
.- Parameters:
condition
- the condition the items must satisfymetricsType
- a String specifying which metrics should be computed, separated by a slash (/
) (possible values:sum
for the sum of the values,avg
for the average of the values,min
for the minimum value andmax
for the maximum value)property
- 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
field- Returns:
- a Map associating computed metric name as key to its associated value
- See Also:
-
getQueryCount
@POST @Path("/{type}/count") public long getQueryCount(@PathParam("type") String type, @QueryParam("validate") Boolean validate, Condition condition, @Context javax.servlet.http.HttpServletResponse response) Retrieves the number of items of the specified type as defined by the Item subclass public fieldITEM_TYPE
and matching the specifiedCondition
.- Parameters:
condition
- the condition the items must satisfyvalidate
- optional parameter, in case of draft condition that have missing required parameters an IllegalArgumentException is throw and this end point will return status code 400, to avoid that you can set validate to false.type
- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPE
fieldresponse
- the httpServletResponse- Returns:
- the number of items of the specified type. 0 and status code 400 in case of IllegalArgumentException (bad condition) and validate null or true 0 and status code 200 in case of IllegalArgumentException (bad condition) and validate false
- See Also:
-