Sure, “j” version:
[
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Sequence",
"~children": [
{
"#operator": "DistinctScan",
"scan": {
"#operator": "IndexScan",
"index": "rec1-1_record_by_index_map",
"index_id": "f5f767dbbf23f38d",
"keyspace": "record",
"namespace": "default",
"spans": [
{
"Range": {
"High": [
"{\"name\":\"key1\",\"value\":\"val1\"}"
],
"Inclusion": 3,
"Low": [
"{\"name\":\"key1\",\"value\":\"val1\"}"
]
}
}
],
"using": "gsi"
}
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Fetch",
"as": "r",
"keyspace": "record",
"namespace": "default"
},
{
"#operator": "Filter",
"condition": "(any `i` in object_pairs((`r`.`indexMap`)) satisfies (`i` = {\"name\": \"key1\", \"value\": \"val1\"}) end and any `j` in object_pairs((`r`.`indexMap`)) satisfies (`j` = {\"name\": \"key2\", \"value\": \"val2\"}) end)"
},
{
"#operator": "InitialProject",
"result_terms": [
{
"as": "doc",
"expr": "`r`"
},
{
"as": "revision",
"expr": "(meta(`r`).`cas`)"
}
]
},
{
"#operator": "FinalProject"
}
]
}
}
]
},
{
"#operator": "Limit",
"expr": "100"
}
]
},
"text": "SELECT r AS doc, meta(r).cas AS revision FROM record AS r WHERE any i in object_pairs(indexMap)satisfies i = { \"name\":\"key1\", \"value\":\"val1\"} end AND any j in object_pairs(indexMap)satisfies j = { \"name\":\"key2\", \"value\":\"val2\"} end LIMIT 100"
}
]
INTERSECT version:
[
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "IntersectAll",
"first": {
"#operator": "Sequence",
"~children": [
{
"#operator": "DistinctScan",
"scan": {
"#operator": "IndexScan",
"index": "rec1-1_record_by_index_map",
"index_id": "f5f767dbbf23f38d",
"keyspace": "record",
"namespace": "default",
"spans": [
{
"Range": {
"High": [
"{\"name\":\"key1\",\"value\":\"val1\"}"
],
"Inclusion": 3,
"Low": [
"{\"name\":\"key1\",\"value\":\"val1\"}"
]
}
}
],
"using": "gsi"
}
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Fetch",
"as": "r",
"keyspace": "record",
"namespace": "default"
},
{
"#operator": "Filter",
"condition": "any `i` in object_pairs((`r`.`indexMap`)) satisfies (`i` = {\"name\": \"key1\", \"value\": \"val1\"}) end"
},
{
"#operator": "InitialProject",
"result_terms": [
{
"as": "doc",
"expr": "`r`"
},
{
"as": "revision",
"expr": "(meta(`r`).`cas`)"
}
]
},
{
"#operator": "Distinct"
},
{
"#operator": "FinalProject"
}
]
}
},
{
"#operator": "Distinct"
}
]
},
"second": {
"#operator": "Sequence",
"~children": [
{
"#operator": "DistinctScan",
"scan": {
"#operator": "IndexScan",
"index": "rec1-1_record_by_index_map",
"index_id": "f5f767dbbf23f38d",
"keyspace": "record",
"namespace": "default",
"spans": [
{
"Range": {
"High": [
"{\"name\":\"key2\",\"value\":\"val2\"}"
],
"Inclusion": 3,
"Low": [
"{\"name\":\"key2\",\"value\":\"val2\"}"
]
}
}
],
"using": "gsi"
}
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Fetch",
"as": "r",
"keyspace": "record",
"namespace": "default"
},
{
"#operator": "Filter",
"condition": "any `i` in object_pairs((`r`.`indexMap`)) satisfies (`i` = {\"name\": \"key2\", \"value\": \"val2\"}) end"
},
{
"#operator": "InitialProject",
"result_terms": [
{
"as": "doc",
"expr": "`r`"
},
{
"as": "revision",
"expr": "(meta(`r`).`cas`)"
}
]
},
{
"#operator": "Distinct"
},
{
"#operator": "FinalProject"
}
]
}
},
{
"#operator": "Distinct"
}
]
}
},
{
"#operator": "Limit",
"expr": "100"
}
]
},
"text": "SELECT r AS doc, meta(r).cas AS revision\r\nFROM record AS r\r\nWHERE ANY i IN OBJECT_PAIRS( indexMap ) SATISFIES i = { \"name\":\"key1\", \"value\":\"val1\" } END\r\nINTERSECT\r\nSELECT r AS doc, meta(r).cas AS revision\r\nFROM record AS r\r\nWHERE ANY i IN OBJECT_PAIRS( indexMap ) SATISFIES i = { \"name\":\"key2\", \"value\":\"val2\" } END\r\nLIMIT 100;"
}
]