How to create an index under CBL Android 2.0 DB018

Please provide a basic example which shows the usage of createIndex(String name, Index index) from Database.java in DB018. Especially how to use Index.java.

The TravelSample sample code provides such an example.

Here is an example of creating a FTS index from Travel Sample App -

Thank you!

And how can I achieve something different than an FTS index?
For example a huge list of dates.

It’s very similar. You create a value index

For example, this creates an index on “type” property

    database.createIndex("typeIndex",Index.valueIndex().on(ValueIndexItem.expression(Expression.property("type"))));
       
1 Like

Is it possible to create an index on two fields?

Actually I found it. Thanks