Couch base Ephemeral bucket query not work

n1ql
query
index

#1

I created one bucket and set it’s type to “Ephemeral” and I tired following query

select * from temp limit 1;

but it show following error

[
{
“code”: 4000,
“msg”: “No index available on keyspace temp 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 * from temp limit 1;”
}
]

Then I tried to create index on that bucket like this

create primary index on temp;

but it show following error

[
{
“code”: 5000,
“msg”: “GSI CreatePrimaryIndex() - cause: Encounter errors during create index. Error=Ephemeral Buckets Must Use MOI Storage\n.”,
“query_from_user”: “create primary index on temp;”
}
]

how I can query on “Ephemeral” bucket?


#2

According to Table 1 https://developer.couchbase.com/documentation/server/current/architecture/core-data-access-buckets.html Global Secondary Indexes doesn’t support Ephemeral buckets. cc @deepkaran.salooja

If you want to use query on Ephemeral buckets you have to use MOI Index storage or KV Gets using document key.


#3

Thanks for your reply, I already looked that link and I’m able to query using following

select * from temp use keys [‘test-0’];

but is possible to run above query instead of passing keys like this

select * from temp;


#4

When query has the keys (USE KEYS) it by passes indexing. Without USE KEYS it needs IndexScan. So it is not possible


#5

Ok got your point but one more thing , is there any way to query on all keys like this

select * from temp use keys [*];

basically I want to query on all those documents because when I tried this query

select meta().id from temp;

it show following error

[
{
“code”: 4000,
“msg”: “No index available on keyspace temp 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 meta().id from temp;”
}
]


#6

USE KEYS needs to be explicitly evaluated to strings no wild cards or *


#7

sorry, but I did not understand this can you explain more because I tried this

select * from temp use keys;

but it show this error

[
{
“code”: 3000,
“msg”: “syntax error - at ;”,
“query_from_user”: “select * from temp use keys;”
}
]
my requirement is how I should query on “Ephemeral” bucket all data ?


#8

Syntax for USE KEYS is

expr needs to evaluated to string or array of strings

To use queries on Ephemeral bucket Index storage mode must be MOI (Available in Enterprise Edition only), or providing document keys as part of query.


#9

Thanks now my all doubts clear, but when I create bucket there no option to index storage mode MOI. is MOI index should create manually or when we create bucket “Ephemeral” then it auto MOI index?


#10

Index Storage Mode option is at cluster level not bucket level. When Index Service added first time in cluster it gives the option for Enterprise edition (may be Community edition MOI is not available so it might not have given that option). You should see in Settings.


#11

Memory Optimized Indexes(MOI) are available in Enterprise Edition Only. If you want to index on Ephemeral bucket, that’s the only supported storage type.