Hi,
Is it possible to create a covered index from function output? Let’s say I have documents with “id” field and the value of “id” can be either an integer or string type.
Can I create a covered index that can be used for the following query?
select id from mybucket where isstring(id) = true
Without understanding how index expression works, I’ve tried the following.
create index idx_test on mybucket(isstring(id))
Explain out:
{
"requestID": "c5e53221-5b58-4d2d-a9b2-ec969fd25b61",
"signature": "json",
"results": [
{
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexScan",
"index": "idx_test",
"keyspace": "mybucket",
"namespace": "default",
"spans": [
{
"Range": {
"High": [
"true"
],
"Inclusion": 3,
"Low": [
"true"
]
}
}
],
"using": "gsi"
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Fetch",
"keyspace": "mybucket",
"namespace": "default"
},
{
"#operator": "Filter",
"condition": "(is_string((`mybucket`.`id`)) = true)"
},
{
"#operator": "InitialProject",
"result_terms": [
{
"expr": "(`mybucket`.`id`)"
}
]
},
{
"#operator": "FinalProject"
}
]
}
}
]
}
],
"status": "success",
"metrics": {
"elapsedTime": "2.770835ms",
"executionTime": "2.734089ms",
"resultCount": 1,
"resultSize": 1969
}
}