
Behavioral require containers
Special behavioural require constraint containers are used to define a require constraint scope.
In Scope
- argument:enum(LIVE|ARCHIVED)
mandatory enum argument naming one of the scopes requested by the query
- requireConstraint:any+
one or more require constraints to evaluate in the named scope
The inScope (
) require container
evaluates the extra results it wraps, such as facet summaries, histograms, and hierarchy statistics, in the named
scope: from the indexes of that scope and the entities the query matches there, each extra result by its own counting
rules. Histograms follow the
histogram baseline rules.
An unwrapped histogram covers all scopes the query searches. The price histogram, the histogram of an attribute, and
a named histogram of a reference can each be requested for one scope set per query. Requests for the same histogram
with different scope sets are rejected.
An extra result requires its indexes in every scope it is planned in. A query that searches both scopes can wrap an
extra result in inScope naming the scope that has them.
The main entityFetch fetches its requested content for every returned entity, regardless of scope, even when
it appears inside a require-level inScope. Its content constraints are checked in the scopes the content is fetched
in - every scope the query searches, unless a reference filter selects the scopes of the referenced entities.
The scope named by inScope must be one the query requests. A query that searches only ARCHIVED rejects
inScope(LIVE, ...).
An inScope container cannot be nested in another inScope container within the same requirement context. With
a different scope the inner requirements would apply only to entities that are in both scopes at once, which none are,
and with the same scope the inner container would be redundant - so the query is rejected with an error in both cases.
Place the containers side by side instead. The rule does not reach into a requirement that describes the content of
other entities - such as entityFetch, referenceContent, facetSummary or hierarchyOfReference.
For example, in our demo dataset we haven't created facet or hierarchy indexes for archived entities. The price
information is also not indexed. So if you tried to calculate facet summary or histogram information for entities in
the archive scope, you'd get an error from the query engine. If you are querying entities in multiple scopes, you should
use the inScope container and limit these calculations to only those scopes where the indexes are prepared:
As you can see, the result contains calculations for the data that the engine can calculate.
Place the main entityFetch beside the inScope container. When querying products in both scopes, this require
section fetches the code of every returned product and computes the price histogram for matching live products,
using the price histogram baseline.
Similar inScope containers are available for filter constraints
and ordering constraints with the same purpose and meaning.
Some require constraints allow results from multiple references to be combined. For example, reference summary,
attribute histogram and price histogram can be
computed for both live and archived entities if the appropriate indices are available.
