Couch base Ephemeral bucket query not work

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?

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.

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;

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

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;”
}
]

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

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 ?

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.

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?

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.

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.