Sorting using full text search does not sort on the entire contents of the property

We are using Couchbase 4.6.2 and trying to use the full text search feature.w Our attempt is to search, sort, and paginate.

The issue we are running into is, when the FTS feature sorts the records, it sorts based on a single word in the field. Based on the documentation, it seems this is because of how full text search indexing works (and the analyzer that is chosen in the index). It takes each word and creates an index on that. Then when sorting is performed, it chooses either min or max values for that field and sorts on that value

Is it possible to have the FTS index the fields on the per-word basis as it does now, but have the sort operate on the entire content of the property?

If you want to search on a field, you typically want it to be analyzed, which means the individual terms end up in the index. However, if you want to sort on the entire original value, then you must ensure it is in the index unchanged. Fortunately, FTS allows you to index a single field multiple ways.

So, in this case we’d recommend indexing the field once for search purposes (as it sounds like you’re already doing) and a second time (under a different name like 'title_sort). For this field you configure the ‘keyword’ analyzer which indexes the original content unchanged. Then when sorting, you specify title_sort, not title.