This makes sense to me but how do you explain the following:
I start a new couchbase cluster. Create new bucket named “mybucket”
I create 2 new documents:
key: transaction::1 value: {"docvalkey1":"docvalkey1-val1","docvalkey2":"docvalkey2-val1"}
key: transaction::2 value: {"docvalkey1":"docvalkey1-val2","docvalkey2":"docvalkey2-val2"}
In couchbase administration I goto: localhost:8091 then to Query screen.
I type the following query that queries by value:
select docvalkey1 FROM
mybucketWHERE docvalkey1 = 'docvalkey1-val1'
I get back as result:
[
{
"code": 4000,
"msg": "No index available on keyspace mybucket that matches your query. Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online.",
"query_from_user": "select docvalkey1 FROM `mybucket` WHERE docvalkey1 = 'docvalkey1-val1'"
}
]
I then create a primary index:
CREATE PRIMARY INDEX
mybucket-primary-indexON
mybucket` USING GSI;
I then rerun the above query on values:
select docvalkey1 FROM
mybucketWHERE docvalkey1 = 'docvalkey1-val1'
and low and behold this time I do get the results, the only change is that I create the primary index this time:
[
{
"docvalkey1": "docvalkey1-val1"
}
]
How come only after adding the primary index it agreed to do a query on the values? doesn’t that means that primary index indexes values? if not why does it force me to create it to query by values?