The
stratify relevance ranking module is used to boost or bury
records in the result set.
The
stratify relevance ranking module ranks records by
stratifying them into groups defined by EQL expressions. The module can be
used:
- in record search options,
via the
Ntx URL query parameter or the
ERecSearch class.
- as a component of a sort
specification given as the default sort or in the API via the
Ns URL query parameter or the
ENEQuery.setNavActiveSortKeys() method.
The
stratify module takes an ordered list of one or more
EQL expressions that are used for boosting/burying records. The following
example shows one EQL expression for the module:
N=0&Ntx=mode+matchall+rel+stratify(collection()/record[Score>95],*)&Ntk=WineType&Ntt=merlot
This record search example queries for the term
merlot in WineType values. Any record that has a
Score value of greater than 95 will be boosted in relation to other records.
Note: When used for sort operations, you must prepend the
Endeca prefix to the
stratify module name for use in the sort
specification (i.e., use
Endeca.stratify as the name).
EQL expressions and record strata
Each EQL expression used in the
stratify statement corresponds to a stratum, as does
the set of records which do not match any expression, producing
k + 1 strata (where
k is the number of EQL expressions). Records are placed in the
stratum associated with the first EQL expression they match. The first stratum
is the highest ranked, the next stratum is next-highest ranked, and so forth.
Note a record will be stratified in the highest strata it matches, so boosting
will have priority over burying.
If a record matches none of the specified EQL expressions, it is
assigned to the
unmatched stratum. By default, the unmatched stratum is ranked
below all strata. However, you can change the rank of the unmatched stratum by
specifying an asterisk (*) in the list of EQL expressions. In this case, the
asterisk stands for the unmatched stratum.
The rules for using an asterisk to specify the unmatched stratum are:
- If an asterisk is
specified instead of an EQL expression, unmatched records are placed in the
stratum that corresponds to the asterisk.
- If no asterisk is
specified, unmatched records are placed in a stratum lower than any
expression's stratum.
- Only one asterisk can be
used. If more than one asterisk is specified, the first one will be used and
the rest ignored.
This
Ntx snippet shows the use of an asterisk in the query:
N=0&Ntx=rel+stratify(collection()/record[Score>90],*,collection()/record[Score<50])
The query will produce three strata of records:
- The highest-ranked stratum
will be records whose Score value is greater than 90.
- The lowest-ranked stratum
will be records whose Score value is less than 50.
- All other records will be
placed in the unmatched stratum (indicated by the asterisk), which is the
middle-ranked stratum.
Note that the EQL expressions must be URL-encoded. For example, this
query:
collection()/record[status = 4]
should be issued in this URL-encoded format:
collection%28%29/record%5Bstatus%20%3D%204%5D
However, the examples in this chapter are not URL-encoded, in
order to make them easier to understand.