Meta Query on TTL expiration fields

Hi, I created TTL and set expiry and my meta look like as below :
{
“id”: “test0”,
“rev”: “10-151a276e9c2700005aa2145702000000”,
“expiration”: 1520571479,
“flags”: 33554432
}

and I run N1QL as below :

select Meta(Demo).expiration from Demo;

but it return all blanks like this :

[
{
“expiration”: 0
},
{
“expiration”: 0
},
{
“expiration”: 0
}
]

so how I can query on expiration meta key ? I want to find out next expiration documents.

META().expiration will give 0 for non covered queries. This is known issue.
You can create index on expiration and do covered query

CREATE INDEX ix1 ON Demo(META().expiration);
SELECT META().id, META().expiration FROM Demo WHERE  META().expiration IS NOT NULL;
1 Like

What shoud I do, if it doesn’t work for me? Explain says that it always rides a primary index.

I’m using: Community Edition 6.0.0 build 1693 ‧ IPv4

It should post your query.