Details
-
Bug
-
Resolution: Fixed
-
Major
-
6.6.0, Cheshire-Cat
-
Untriaged
-
1
-
Unknown
Description
Build:7.0.0 build 2083, 6.6.0 build 7661
- Load dataset attached
- mutated is common field which is in both "wiki" and "emp" type documents
- Create multitypemapping fts index below, where in mutated is indexed in "wiki" type but not in "emp" type:
{
"type": "fulltext-index",
"name": "custom_index",
"uuid": "6c6131cb3dffe4ef",
"sourceType": "couchbase",
"sourceName": "default",
"planParams": {
"maxPartitionsPerPIndex": 171
},
"params": {
"doc_config": {
"docid_prefix_delim": "",
"docid_regexp": "",
"mode": "type_field",
"type_field": "type"
},
"mapping": {
"analysis": {},
"default_analyzer": "standard",
"default_datetime_parser": "dateTimeOptional",
"default_field": "_all",
"default_mapping": {
"dynamic": true,
"enabled": false
},
"default_type": "_default",
"docvalues_dynamic": true,
"index_dynamic": true,
"store_dynamic": false,
"type_field": "type",
"types": {
"emp": {
"dynamic": false,
"enabled": true,
"properties": {
"dept": {
"dynamic": false,
"enabled": true,
"fields": [
{
"analyzer": "keyword",
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "dept",
"type": "text"
}
]
},
"is_manager": {
"dynamic": false,
"enabled": true,
"fields": [
{
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "is_manager",
"type": "boolean"
}
]
},
"join_date": {
"dynamic": false,
"enabled": true,
"fields": [
{
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "join_date",
"type": "datetime"
}
]
},
"manages": {
"dynamic": false,
"enabled": true,
"properties": {
"team_size": {
"dynamic": false,
"enabled": true,
"fields": [
{
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "team_size",
"type": "number"
}
]
}
}
},
"salary": {
"dynamic": false,
"enabled": true,
"fields": [
{
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "salary",
"type": "number"
}
]
}
}
},
"wiki": {
"dynamic": false,
"enabled": true,
"properties": {
"mutated": {
"dynamic": false,
"enabled": true,
"fields": [
{
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "mutated",
"type": "number"
}
]
},
"revision": {
"dynamic": false,
"enabled": true,
"properties": {
"timestamp": {
"dynamic": false,
"enabled": true,
"fields": [
{
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "timestamp",
"type": "datetime"
}
]
}
}
},
"title": {
"dynamic": false,
"enabled": true,
"fields": [
{
"analyzer": "keyword",
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "title",
"type": "text"
}
]
},
"type": {
"dynamic": false,
"enabled": true,
"fields": [
{
"analyzer": "keyword",
"include_in_all": true,
"include_term_vectors": true,
"index": true,
"name": "type",
"type": "text"
}
]
}
}
}
}
},
"store": {
"indexType": "scorch",
"mossStoreOptions": {}
}
},
"sourceParams": {}
}
- Create GSI primary index
- For the below Flex queries, fts index is considered and returns 500 docs where with GSI index it returns 1000 docs
select meta().id from default USE INDEX (USING FTS, USING GSI) where (type = "emp" or type = "wiki") and ( mutated between 0 and 7330)
Explain plan:
{
|
"#operator": "Sequence",
|
"~children": [
|
{
|
"#operator": "IndexFtsSearch",
|
"index": "custom_index",
|
"index_id": "6c6131cb3dffe4ef",
|
"keyspace": "default",
|
"namespace": "default",
|
"search_info": {
|
"field": "\"\"",
|
"options": "{\"index\": \"custom_index\"}",
|
"outname": "out",
|
"query": "{\"query\": {\"disjuncts\": [{\"field\": \"mutated\", \"inclusive_max\": true, \"inclusive_min\": true, \"max\": 7330, \"min\": 0}, {\"field\": \"mutated\", \"inclusive_max\": true, \"inclusive_min\": true, \"max\": 7330, \"min\": 0}]}, \"score\": \"none\"}"
|
},
|
"using": "fts"
|
},
|
{
|
"#operator": "Fetch",
|
"keyspace": "default",
|
"namespace": "default"
|
},
|
{
|
"#operator": "Parallel",
|
"~child": {
|
"#operator": "Sequence",
|
"~children": [
|
{
|
"#operator": "Filter",
|
"condition": "((((`default`.`type`) = \"emp\") or ((`default`.`type`) = \"wiki\")) and ((`default`.`mutated`) between 0 and 7330))"
|
},
|
{
|
"#operator": "InitialProject",
|
"result_terms": [
|
{
|
"expr": "(meta(`default`).`id`)"
|
}
|
]
|
},
|
{
|
"#operator": "FinalProject"
|
}
|
]
|
}
|
}
|
]
|
}
|
It is understood that, with FTS index it returns 500 docs because FTS index only has 500 docs with mutated =0, but with primary gsi index is having all type docs with mutated=0, so it returns 1000 docs.
Question is, in this case, flex query with (USING FTS, USING GSI) should consider GSI index rather than FTS ?