Could not dropped text index

I am trying to change the text index setting, but the existing text index is not deleted.

Reproduce

A text index is created as shown below.

db.users.getIndexes()
[
  {
    "key": {
      "_fts": "text",
      "_ftsx": 1
    },
    "name": "search_terms_text",
    "ns": "db.users",
    "v": 2,
    "default_language": "english",
    "language_override": "language",
    "textIndexVersion": 3,
    "weights": {
      "search_terms": 1
    }
  }
]

I did dropIndex with the index name as shown below, and got the result that it was successful.

db.users.dropIndex("search_terms_text")
[
  {
    "$clusterTime": {
      "clusterTime": {"$timestamp": {"t": 1645773616, "i": 473}},
      "signature": {
        "hash": {"$binary": {"base64": "CH0lkqS6u83NeFP5Xd3y3NDVJKw=", "subType": "00"}},
        "keyId": 7014029826021392388
      }
    },
    "nIndexesWas": 2,
    "ok": 1,
    "operationTime": {"$timestamp": {"t": 1645773616, "i": 473}}
  }
]

When I try to re-create the text index after deletion, I get an error message stating that it already exists as shown below.

db.users.createIndex(
    { search_terms: "text" },
    { default_language: "none" }
)
Command failed with error 85 (IndexOptionsConflict): 'Index with name: search_terms_text already exists with different options' on server ***. The full response is {"operationTime": {"$timestamp": {"t": 1645773721, "i": 183}}, "ok": 0.0, "errmsg": "Index with name: search_terms_text already exists with different options", "code": 85, "codeName": "IndexOptionsConflict", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1645773721, "i": 183}}, "signature": {"hash": {"$binary": {"base64": "njwxfSeASmTReFUzs/tZFBJv34k=", "subType": "00"}}, "keyId": 7014029826021392388}}}

When I call getIndexes() again, I could see that the text index was not deleted and remained.

db.users.getIndexes()
[
  {
    "key": {
      "_fts": "text",
      "_ftsx": 1
    },
    "name": "search_terms_text",
    "ns": "db.users",
    "v": 2,
    "default_language": "english",
    "language_override": "language",
    "textIndexVersion": 3,
    "weights": {
      "search_terms": 1
    }
  }
]

DB Logs

When I check the DB log in that time period, it is as follows.

1. index build: done building index search_terms_text on ns db.users
2. Deferring table drop for index 'search_terms_text' on collection 'db.users.$search_terms_text (8082e0dc-6416-43f1-97a6-26101033e5ea)'. Ident: 'db/index-183-7199585454386394577', commit timestamp: 'Timestamp(1645773616, 473)'
3. index build: inserted 551 keys from external sorter into index in 0 seconds
4. index build: collection scan done. scanned 17 total records in 0 seconds
5. index build: starting on db.users properties: { v: 2, key: { _fts: "text", _ftsx: 1 }, name: "search_terms_text", ns: "db.users", weights: { search_terms: 1 }, default_language: "english", language_override: "language", textIndexVersion: 3 } using method: Hybrid
6. Completing drop for ident db/index-183-7199585454386394577 (ns: db.users.$search_terms_text) with drop timestamp Timestamp(1645773616, 473)

Environment

mongodb version: 4.2.12
replica set: primary 1, secondary 2

Question

  1. Why do text indexes keep regenerating?
  2. If I can’t drop the text index, is there a way to change the default_language setting?

Thanks to everyone who replied.

Hi @Joe_Cho and welcome in the MongoDB community :muscle: !

Initially I thought it could be a MongoDB Atlas Search index that was automatically being recreated because its definition is in Atlas - but I just tested and actually these Lucene indexes don’t even appear in the normal list of indexes so that’s not it.

The only thing I can think of is that maybe you have Mongoose or Java with POJOs running on top of this collection and they have an index definition applied directly in the config of the Object files that represent that collection and they recreate the index automatically if it detects that it doesn’t exists.

To be honest, that the only thing I can think of.

Let me know if you find the solution :smiley: !

Cheers,
Maxime.

1 Like

Hi~ @MaBeuLux88 Thanks for your reply.

Currently, I am using https://github.com/mongodb/mongo-go-driver and I am not creating any index in the application. And as far as I know, mongo-go-driver does not automatically create indexes. If it’s not automatically recreated in mongodb as you explained, I can think of it as regenerating somewhere. I’ll take a look again.

Thanks,
Joe, Cho

1 Like