Question about the query documentation of Couchbase lite 2.0

15 views
Skip to first unread message

hyun...@wisefour.com

unread,
Sep 15, 2017, 11:45:04 AM9/15/17
to Couchbase Mobile
I'm very excited that Couchbase lite 2.0 supports N1QL query language. 

When I read the documentation, I found the below statements on the Query Indexing section. 

To create an index, call  d passing an array of one or more strings.

I can't understand the exact meaning of it. Is there anyone to explain what it is and show the java example code??


Priya Rajagopal

unread,
Sep 15, 2017, 11:49:31 AM9/15/17
to Couchbase Mobile
The statement means that you can specify the list of properties that you want to index on as an array. 

Something like this ...

private void createDatabaseIndex() {
try {

 // Regular value type index
        List<Expression> valueProp = new ArrayList<Expression>();
valueProp.add(Expression.property("type"));
database.createIndex(valueProp);

// Create full text search index
List<Expression> ftsProp = new ArrayList<Expression>();
ftsProp.add(Expression.property("overview"));
database.createIndex(ftsProp, IndexType.FullText, new IndexOptions("en", true));
}
catch (CouchbaseLiteException e) {
e.getStackTrace();
}

}

Jens Alfke

unread,
Sep 15, 2017, 1:47:42 PM9/15/17
to mobile-c...@googlegroups.com


On Sep 15, 2017, at 4:35 AM, hyun...@wisefour.com wrote:

When I read the documentation, I found the below statements on the Query Indexing section. 

To create an index, call  d passing an array of one or more strings.

This is a glitch in the web page: that "d" is supposed to be "CreateIndex()". The text changes depending on what language you select at the top of the page; the other languages work, but the Java text is broken. 

I clicked the Feedback link at the bottom of the page to report the problem; feel free to do the same if you find any more problems.

—Jens
Reply all
Reply to author
Forward
0 new messages