How to use index in couchbase ios


#1

Hi,
I am trying to add index into my database for faster searching. However, none of the document give specific example of how to apply and use index. I wonder if someone can provide me example in swift of how to apply nested index and search based on it.

Thank you very much


#2

Can you clarify what you mean by nested indexes with an example ? Are you looking for array indexes - we don’t have that in 2.0

We have plenty of resources that discuss indexing in CBL 2.0.


#3

Hi,

My data may look like this:
([“chat_collection”: {
“0000865d-e2bc-4c82-a7b7-d9ee58b4736f” = {
“chat_id” = 5afe0a502575138403f0e34c;
from = 5925fa4c3380d30eeae6d066;
id = “0000865d-e2bc-4c82-a7b7-d9ee58b4736f”;
“is_image_group” = 0;
“is_local” = 0;
“self_liked” = 0;
state = 0;
text = uqlQR;
to = 5ae8e945c5f56b92bc6708f3;
ts = “2018-05-21T20:32:31.016000”;
type = T;
};
“0002e482-9079-4707-9585-a1bd35213c2b” = {
“chat_id” = 5afc62c9b68e324c213d419f;
from = 5ad11f02c5f56b40291990ee;
id = “0002e482-9079-4707-9585-a1bd35213c2b”;
“is_image_group” = 0;
“is_local” = 0;
“self_liked” = 0;
state = 0;
text = as;
to = 5ae8e945c5f56b92bc6708f3;
ts = “2018-05-21T20:32:32.494000”;
type = T;
};}])

I want to set index to message id and search by it. In this case, id are 0000865d-e2bc-4c82-a7b7-d9ee58b4736f and 0002e482-9079-4707-9585-a1bd35213c2b.

Thank you very much