Each returned item set may contain index items, depending on the other search parameters. Normally, the index items are returned in index order, but user interfaces often allow the final results to be sorted by some secondary criteria, such as date or source or format. The index item sorting is controlled by the following attributes:
<browse docSort="mode
" docSortOrder="order
" docSortProp="prop
"
docSortPropDefault="def
" docSortPropVal="val
" docSortPred="predicate
"
docSortCase="bool"
The mode
value specifies how the index items will be sorted, and can be one of the following:
relevance
—The default value, return items in relevance order, assuming the item set is a categoryalpha
—Sort index items by filename, (such asindex.htm
)address
—Sort index items by the beginning of the full URL (for example,http://www.mycorp.com
)url
—Sort index items by full URLdate
—Sort index items by last modified datestrprop
—Sort index item by a metadata string property, requiresdocSortProp
attributenumprop
—Sort index items by a metadata number property, requiresdocSortProp
attributetitle
—Sort index items by titletype
—Sort index items by the type, such as HTML or PDFdocset
—Sort index items by physical document setindex
—Leave index items unsorted, in index orderpredicate
– Sort groups by combination of the modes specified in thedocSortPred
attribute (see below).
The order
value determines whether the sort is ascending or descending, either alphabetically or numerically, depending on the sort mode. The order
value can be either ascending
or descending
.
The prop
value specifies the property name to use for the strprop
or numprop
modes. The property name must be a valid property of the given type; for example, for strprop
, either string
or enum
, and for numprop
, either integer
, float
, boolean
or date
. Index items that don’t have this property will be excluded from the sort. To prevent that, the def
value can specify the default property value to use for these exceptional cases. The def
value should agree with the type of the property.
When grouping by property, it is common to have multiple values for a property within an item as well as across a group. The val
value controls which value of the result group’s properties to use. The val
can be one of the following values:
first
—The first value of the first item in the group is used.last
—The last value of the last item in the group is used.high
—The highest (greatest) value of the property from any of the items in the group.low
—The lowest (smallest) value of the property from any of the items in the group.
The default is first
. As an example, if the items should be sorted by the lowest price and there are multiple price values per item or the items are grouped by some property, the low value for docSortPropVal
should be used.
The predicate
value specifies a sequence of sorting modes and orders to apply when mode="predicate"
, forming a complex sort criterion. The value has the following form:
docSort="predicate" docSortPred="mode:order:prop:def:bool|…"
The five colon-delimited fields correspond to the five docSort
attribute values. Note that for modes other than strprop
and numprop
, the prop
and def
fields are irrelevant and can be omitted. The order
value should specify the logical precedence of the mode
, that is, how the results would be placed in order by that individual mode. The bool
represents the docSortCase
value.
The overall sort order is controlled using the docSortOrder
attribute. For example:
docSortPred="numprop:descending:popularity:0|numprop:ascending:cost"
docSortOrder="ascending"
In this example, search results are first sorted descending by popularity, then ascending by cost (for results where popularity is the same).
The docSortCase
attribute determines whether any string secondary sorting is case-sensitive (true
) or not (false
). This attribute affects the docSort
mode
values of strprop
, alpha
, url
, address
, and title
. The sort predicate specifies its case-sensitivity within its fielded format.