By default, the Full-Text Search engine sorts the result set by the score pseudo column in descending order (the higher scores appear first). To change the default sort order, set the sort_order configuration parameter to one of the values in Table 6-8.
Value |
Description |
---|---|
0 |
Returns result sets sorted by the score pseudo column in descending order. The default value. |
1 |
Returns result sets sorted by the score pseudo column in ascending order. |
2 |
Returns result sets sorted by a timestamp in descending order. |
3 |
Returns result sets sorted by a timestamp in ascending order. |
For example, with the Enhanced Full-Text Search engine, enter:
sp_text_configure KRAZYKAT, ’sort_order’, ’2’
When you sort a result set by descending timestamp (value 2 in Table 6-8), the Full-Text Search engine returns the newest documents first. The newest documents are those that were inserted or updated most recently. When results are sorted by ascending timestamp (value 3 in Table 6-8), the Full-Text Search engine returns the oldest documents first.
Setting the default sort order is especially important if your query uses the max_docs pseudo column. The max_docs pseudo column limits the number of rows of the result set to the first n rows, ordered by the sort order. If you set max_docs to a number smaller than the size of the result set, the sort order you select could exclude the rows that contain the information for which you are searching.
For example, if you sort by ascending timestamp, the latest document added to the table appears last in the result set. If the entire result set consists of 11 documents, and you set max_docs to 10, the latest document does not appear in the result set. However, if you sort by descending timestamp, the latest document appears first in the result set.