Queries are especially likely to be unique if they have constraints that include timestamps. For example, suppose you configure queries to include a constraint that removes items whose start date is in the future (i.e., items that are not yet available). To do this, you might create a component of class atg.search.routing.command.search.PropConstraint
and configure it so that an item is returned only if the value of its startDate
property is less than or equal to the current date and time. Unfortunately, this constraint results in every query being unique, because the time changes continuously. So no benefit can be realized by caching the queries.
To prevent these queries from being unique, the Oracle ATG Web Commerce platform includes the class atg.service.util.ChunkedTimeInterval
. This class divides up time into discrete intervals of a specified length, and during an individual interval always returns the same time. If you use this class to include timestamps in search queries, all queries created during an individual interval will have identical timestamps, so queries that are otherwise identical will remain identical. At the end of one interval, a new interval begins and the timestamp changes, but then remains constant for the duration of the new interval.
ChunkedTimeInterval
has intervalUnitName
and intervalCount
properties for specifying the length of the interval. For example, to specify an interval of 4 hours:
intervalUnitName=hour
intervalCount=4
ChunkedTimeInterval
has startTime
and endTime
properties that it sets to the time at the beginning and end of the interval (in milliseconds, using Coordinated Universal Time). So, for example, if an interval is 4 hours long and begins at 4:00 am on July 3, 2010, then startTime
is set to 4:00 am of that day and endTime
is set to 8:00 am. ChunkedTimeInterval
also has a number of other properties that it sets to the interval start and end times in different formats. For search constraints, use either the startTimeSecondsAsString
or the endTimeSecondsAsString
property, as these properties return the time in a format that is most suited to inclusion in search queries.
The DCS.Search.Query
module includes a ChunkedTimeInterval
component named /atg/commerce/search/catalog/ProductAvailabilityTimeWindow
which is configured to use intervals of one day. You can change this interval or create your own component of this class. The following example shows a PropConstraint
properties file that uses this component to include a timestamp in a constraint:
type=integer
name=startDate
operation=lesseq
value^=/atg/commerce/search/catalog/\
ProductAvailabilityTimeWindow.startTimeSecondsAsString
For more information about the ChunkedTimeInterval
class, see the ATG Platform API Reference.