How to use Rank function

Hello, i want to get ranking for FTS search and order results but can’t find how to do that in documentation. There is just a few sentences without any examples https://docs.couchbase.com/couchbase-lite/current/java-platform.html#ordering-results. I am using java sdk and i want to get this value in both select and order statements. Is it possible? Another question is where i can find library sources( classes, functions ) for couchbase lite java sdk, can’t find all together in github repository

It looks like i found answer. https://docs.couchbase.com/mobile/2.6.0/couchbase-lite-java/com/couchbase/lite/FullTextFunction.html Here is example how to use it:

Expression ftsExp = FullTextExpression.index("myFTSIndex").match(value) ;
        Query searchQuery = QueryBuilder
                .select(SelectResult.all(), SelectResult.expression(FullTextFunction.rank("myFTSIndex")).as("rank"))
                .from(DataSource.database(database))
				.where(ftsExp)

documentation is so poor :slightly_frowning_face:

Hey @Sergey_Zhukov: That feature is documented here:
https://docs.couchbase.com/couchbase-lite/2.7/java-android.html#full-text-search

We’ve been working on our docs a lot recently. I’m putting in a request for an example in discussion of you to use a ranking function.

The blog post gives you examples on ranking. Example is in swift but easily mappable to other languages.

In general our blogs are a good place to look for examples, tutorials and how-to guides outside of our docs. In future, we’ll will be adding relevant reference links in our docs.