Quantcast
Channel: Mobile - Couchbase Forums
Viewing all articles
Browse latest Browse all 1119

CB Indexes with some common properties

$
0
0

Hi,

I would like to know the best approach for making the CB indexes in the following case.

Suppose I have 2 different indexes

let index = IndexBuilder.valueIndex(items:
    ValueIndexItem.expression(Expression.property("type")),
    ValueIndexItem.expression(Expression.property("backendState")),
    ValueIndexItem.expression(Expression.property("number")),
    ValueIndexItem.expression(Expression.property("isCompleted")),
    ValueIndexItem.expression(Expression.property("systemStatus")),
    ValueIndexItem.expression(Expression.property("name")))
try database.createIndex(index, withName: "FirstIndex")

And

let index = IndexBuilder.valueIndex(items:
    ValueIndexItem.expression(Expression.property("type")),
    ValueIndexItem.expression(Expression.property("backendState")),
    ValueIndexItem.expression(Expression.property("systemStatus")),
    ValueIndexItem.expression(Expression.property("editedBy")),
    ValueIndexItem.expression(Expression.property("cancelledBy")),
    ValueIndexItem.expression(Expression.property("completedBy")),
    ValueIndexItem.expression(Expression.property("reason")))
try database.createIndex(index, withName: "SecondIndex")
  1. Here the two indexes are sharing common properties. The properties type, backendState and systemStatus are common.
  2. Some of the properties in this index won’t present always based on the type of the document. The properties completedBy and cancelledBy are mutually exclusive.

What is the best way to create the indexes in such scenarios?

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1119

Trending Articles