# Sort

The method to use to order the query results. By default, IDOL Server displays results in order of relevance. If several documents have the same relevance, IDOL Server orders them by the `autn:docid` (document ID) number.

You can use one of the following sorting options:

- `Off`. Do not sort documents.

- `AutnRank`. Sort documents by the value in their AutnRankType field. The document with the highest AutnRankType field value is listed first.

- `Cluster`. Sort documents by decreasing cluster ID. To use this option, you must set Cluster to `True`.

- `Database`. Sort documents by increasing database number. The database numbers are defined in the IDOL Server configuration file.

- `Date`. Sort documents by their date (the date contained in the result DateType fields). The most recent document is listed first.

  If several documents have the same date, IDOL Server orders them by the `autn:docid` (document ID) number (the highest `autn:docid` is listed first).

- `Distcartesian`. Sort documents according to their distance from a point, specified in Cartesian coordinates (X/Y). When you set XMLMeta to `True`, the action returns the calculated distance in a `<autn:fieldsortvalue>` tag in the response. Use the following format:

      &Sort=Distcartesian{coordX,coordY}:POSITION

  where,

  - `coordX` is the specified x coordinate.

  - `coordY` is the specified y coordinate.

  - `POSITION` is either:

    - a single document field that contains the position information in Well-known text format POINT definitions. This field must be a unified GeospatialType field.
    - two fields, in the format `X:Y`, where `X` is the document field that contains the X coordinates, and `Y` is the document field that contains the Y coordinates. These fields must be either GeospatialType or NumericType fields. You must specify the fields in the order X:Y.

  For example:

      &Sort=Distcartesian{10,11}:X:Y

  In this example, IDOL Server sorts documents according to their distance from the point (10,11). The position of a document in this example is contained in the fields `X` and `Y`, respectively.

- `Distspherical`. Sort documents according to their distance from a point, specified in spherical coordinates (latitude and longitude). When you set XMLMeta to `True`, the action returns the calculated distance in a `<autn:fieldsortvalue>` tag in the response. Use the following format:

      &Sort=Distspherical{lat,long}:LOCATION

  where,

  - `lat` is the specified latitude. Specify latitude positions south of the equator as negative.

  - `long` is the specified longitude. Specify longitude positions west of the Greenwich Meridian as negative.

  - `LOCATION` is either:

    - a single document field that contains the location information in Well-known text format POINT definitions. This field must be a unified GeospatialType field.
    - two fields, in the format `Latfield:Longfield`, where `Latfield` is the document field that contains the latitude, and `Longfield` is the document field that contains the longitude. These fields must be either GeospatialType or NumericType fields. You must specify the fields in the order `latitude:longitude`.

For example:

    &Sort=Distspherical{37.75,-122.4}:Location

In this example, IDOL Server sorts documents according to their distance from San Francisco (37.75N,122.4W). The latitude and longitude position of a document in this example is contained in the `Location` field.

- `DocIDDecreasing`. Sort documents by `autn:docid` (document ID). The document with the highest `autn:docid` is listed first.

- `DocIDIncreasing`. Sort documents by `autn:docid` (document ID). The document with the lowest `autn:docid` is listed first.

- `fieldName:sortMethod`. Sort results according to the value of a specified field.

  NOTE: Documents in which the specified field is empty do not return.

  This sort option is optimized when `fieldName` is a MatchType field.

  - `fieldName`. The name of the IDOL Server field to use to determine the document order. You can use fields that you create by using the UserMetaFields parameter.

  - `sortMethod`. The sorting method to apply to the field `fieldName`. The following sorting methods are available:

    `alphabetical` | Sort documents alphabetically by the value of the `fieldName` field. NOTE: IDOL Server can perform the sorting process more quickly if `fieldName` is a MatchType field.
    `decreasing` | Sort documents by decreasing order of the value in the `fieldName` field. The result with the highest number, or last in alphabetical order, is listed first. You can sort by the following metadata fields: `<autn_langtype>` `<autn_language>` `<autn_nodesize>` `<autn_refnodesize>` `<autn_distincttermsperdoc>` `<autn_termsperdoc>` NOTE: For NumericType fields, this method is equivalent to `numberdecreasing`. For MatchType fields, this method is equivalent to `reversealphabetical`.
    `increasing` | Sort documents by increasing order of the value in the `fieldName` field. The result with the lowest number, or first in alphabetical order, is listed first. You can sort by the following metadata fields: `<autn_langtype>` `<autn_language>` `<autn_nodesize>` `<autn_refnodesize>` `<autn_distincttermsperdoc>` `<autn_termsperdoc>` NOTE: For NumericType fields, this method is equivalent to `numberincreasing`. For MatchType fields, this method is equivalent to `alphabetical`.
    `numberdecreasing` | Sort documents by decreasing order of the number in the `fieldName` field. NOTE: IDOL Server can perform the sorting process more quickly if `fieldName` is a NumericType field.
    `numberincreasing` | Sort documents by increasing order of the number in the `fieldName` field. NOTE: IDOL Server can perform the sorting process more quickly if `fieldName` is a NumericType field.
    `reversealphabetical` | Sort documents by the reverse alphabetical order of the value in the `fieldName` field. NOTE: IDOL Server can perform the sorting process more quickly if `fieldName` is a MatchType field.

- `Random`. Sort documents randomly.

- `Relevance`. Sort documents by their relevance (the document with the highest relevance is listed first).

  If several documents have the same relevance, IDOL Server orders them by the `autn:docid` (document ID) number (the highest `autn:docid` is listed first).

- `ReverseDate`. Sort documents by their date (the date contained in the DateType field). The oldest document is listed first.

  If several documents have the same date, IDOL Server orders them by the `autn:docid` (document ID) number (the highest `autn:docid` is listed first).

- `ReverseRelevance`. Sort documents in reverse order of relevance (the document with the lowest relevance is listed first).

  If several documents have the same relevance, IDOL Server orders them by the `autn:docid` (document ID) number (the lowest `autn:docid` is listed first).

If you want to sort results by several criteria, specify these criteria in order of precedence, as follows:

    sortOption1+sortOption2+...

NOTE: if you set `Cluster` as one of multiple sorting options, it automatically takes precedence over the other sorting options, regardless of its position in the list.

For example:

    &Sort=Relevance+DRETITLE:alphabetical+Date

In this example, results order first by `Relevance`, then alphabetically by `DRETITLE`, and finally by `Date`.

Actions: | Query Suggest SuggestOnText
Type: | String
Default: | Relevance
Example: | `Sort=Date`
See Also: | UserMetaFields AutnRankType configuration parameter NumericType configuration parameter MatchType configuration parameter SortComparisonMethod configuration parameter

_FT_HTML5_bannerTitle.htm