FTS index not honoring the type field specified

Hi CB Team,
I created an FTS index (asset_index) with a type mapping using JSON type field keeping an expectation that, this index would index only those documents with the specified type field (type=asset), but here the value in “doc count” column is confusing because it is showing a count greater than we expected.

|index name|bucket|doc count |indexing progress|
|asset_index|shadows|47455|100.0%|

I have 47455 documents in the bucket which contains two types of documents (type=“asset” and type=“task”).
There are 47453 task and 2 asset documents, so I was expecting the “doc count” column to show 2 for asset_index instead it shows 47455.

So the questions are:

  1. What is the meaning of “doc count” field?
  2. Is the FTS index asset_index honoring the type field?

Example for “asset” document:
{
“id”: “asset:14079256057”,
“pid”: null,
“type”: “asset”,
“category”: “aircondition”,
“placeid”: “0001c2f9-605f-45e0-9e81-b86f91317504”,
“status”: “inservice”,
“rating”: “Good”,
“displayName”: “Goodman Central Air Conditioners”,
“warranty”: “5 year warranty”,
“totalLifespan”: 10,
“make”: “Goodman”,
“model”: “GPC15H”,
“year”: 2019,
“since”: 2020,
“connectivity”: true,
“noiceLevel”: 74,
“price”: 2536,
“priceCurrency”: “USD”,
“maxVoltage”: 253,
“weight”: 420,
“height”: 30,
“width”: 66.5,
“depth”: 34,
“reviews”: “This is pretty good AC!”
}

Example for “task” document:
{
“type”: “task”,
“id”: “task:140298393939”,
“cratloc”: “2019-12-04T21:28:15.149”,
“gblwrk”: “inspection-point”,
“chtitle”: " !!",
“doso”: “checkmark”,
“lcattp”: “ptr:1234566”,
“crrole”: “Property Manager”,
“subd”: " !!”
“escState”: “initial”,
“lto”: “America/New_York”,
“wspd”: “inspection”
}

The asset index definition:
{
“name”: “asset_index”,
“type”: “fulltext-index”,
“params”: {
“doc_config”: {
“docid_prefix_delim”: “”,
“docid_regexp”: “”,
“mode”: “type_field”,
“type_field”: “type”
},
“mapping”: {
“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”: {
“asset”: {
“dynamic”: false,
“enabled”: true,
“properties”: {
“crrole”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“docvalues”: true,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “crrole”,
“store”: true,
“type”: “text”
}
]
},
“displayName”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“docvalues”: true,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “displayName”,
“store”: true,
“type”: “text”
}
]
},
“make”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“docvalues”: true,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “make”,
“store”: true,
“type”: “text”
}
]
},
“model”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“docvalues”: true,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “model”,
“store”: true,
“type”: “text”
}
]
},
“price”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“docvalues”: true,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “price”,
“store”: true,
“type”: “number”
}
]
},
“reviews”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“docvalues”: true,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “reviews”,
“store”: true,
“type”: “text”
}
]
},
“since”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“docvalues”: true,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “since”,
“store”: true,
“type”: “number”
}
]
},
“warranty”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“docvalues”: true,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “warranty”,
“store”: true,
“type”: “text”
}
]
},
“year”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“docvalues”: true,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “year”,
“store”: true,
“type”: “number”
}
]
}
}
}
}
},
“store”: {
“indexType”: “scorch”
}
},
“sourceType”: “couchbase”,
“sourceName”: “shadows”,
“sourceUUID”: “d300d62f35d42eac466be688ab70992f”,
“sourceParams”: {},
“planParams”: {
“maxPartitionsPerPIndex”: 171,
“indexPartitions”: 6,
“numReplicas”: 0
},
“uuid”: “6fda3b53123e5e8d”
}

Hey @vishnuchiyyarath ,

  1. What is the meaning of “doc count” field?
    refer - What is doc Count in FTS?

  2. Is the FTS index asset_index honoring the type field?
    Your index defn seems right for asset document types.
    Just note that you have enabled all the field options with the type mappings. This may be sub optimal.
    ref - Full-Text Search Indexing Best Practices & Tips - Part 1.

Cheers!