FTS using alias with 2 indexes Not returning excepted results

USING CB: 6.5.0
DOCS

ID = 1
 {
  "lid": "a",
  "iso": true,
  "type": "foo"
}
ID = 2 
{
  "lid": "b",
  "iso": true,
  "type": "foo"
}

FTS INDEX CALLED “ISO”

{
“type”: “fulltext-index”,
“name”: “iso”,
“uuid”: “466848dd08c7b0f3”,
“sourceType”: “couchbase”,
“sourceName”: “test”,
“sourceUUID”: “56f1e103ed8d8ba5c7f0d0905a895eea”,
“planParams”: {
“maxPartitionsPerPIndex”: 171,
“indexPartitions”: 6
},
“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”: {
“foo”: {
“dynamic”: false,
“enabled”: true,
“properties”: {
“iso”: {
“dynamic”: false,
“enabled”: true,
“fields”: [
{
“analyzer”: “keyword”,
“index”: true,
“name”: “iso”,
“type”: “boolean”
}
]
}
}
}
}
},
“store”: {
“indexType”: “scorch”
}
},
“sourceParams”: {}
}

FTS INDEX 2 CALLED “LID”

{
“type”: “fulltext-index”,
“name”: “lid”,
“uuid”: “3fdf660c104cf4ec”,
“sourceType”: “couchbase”,
“sourceName”: “test”,
“sourceUUID”: “56f1e103ed8d8ba5c7f0d0905a895eea”,
“planParams”: {
“maxPartitionsPerPIndex”: 171,
“indexPartitions”: 6
},
“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”: {
“foo”: {
“dynamic”: false,
“enabled”: true,
“properties”: {
“lid”: {
“dynamic”: false,
“enabled”: true,
“fields”: [
{
“analyzer”: “keyword”,
“index”: true,
“name”: “lid”,
“type”: “text”
}
]
}
}
}
}
},
“store”: {
“indexType”: “scorch”
}
},
“sourceParams”: {}
}

ALIAS

{
“type”: “fulltext-alias”,
“name”: “foo-alias”,
“uuid”: “61babb5c8b31882b”,
“sourceType”: “nil”,
“planParams”: {},
“params”: {
“targets”: {
“iso”: {},
“lid”: {}
}
},
“sourceParams”: null
}

QUERY 1 CONJUCTS: TO /api/index/foo-alias/query

{
“from”: 0,
“explain”: true,
“size”: 100,
“query”: {
“conjuncts”: [
{
“disjuncts”: [
{
“field”: “lid”,
“match”: “a”
},
{
“field”: “lid”,
“match”: “b”
}
]
},
{
“field”: “iso”,
“bool”: true
}
]
}
}

ISSUES:

  • I do not receive any results, I would except to receive both docs back.
  • If I create one index with both fields the query works.

Hi @dipen_patel,

This is working as expected.
Index Alias and it’s purpose are detailed here -

An *index alias* points to one or more Full Text Indexes, or to additional aliases: its purpose is therefore somewhat comparable to that of a symbolic link in a filesystem. Queries on an index alias are performed on all ultimate targets, and merged results are provided.

The use of index aliases permits *indirection* in naming, whereby applications refer to an alias-name that never changes, leaving administrators free periodically to change the identity of the real index pointed to by the alias. This may be particularly useful when an index needs to be updated: to avoid down-time, while the current index remains in service, a clone of the current index can be created, modified, and tested. Then, when the clone is ready, the existing alias can be retargeted, so that the clone becomes the current index; and the (now) previous index can be removed.

So your queries are getting directly pushed to each of the indexes behind the alias and since those indexes don’t have both the fields indexed query is expected to find no matches.

A single FTS index is capable of handling multiple fields as well as multiple type mappings (objects of different schema) and for just querying that you don’t necessarily have to use an index alias.

Cheers!