Mongo DB on Linux (SLES) - How to drop chatlogging events table TTL Index without Compass UI

Dear Folks,

I´ve question about MongoDB and dropping a TTL index in console mode.

I´m using mongo DB on a SLES and have modified the chatlogging.ini as described in "How to change Sametime Persistent Chat 'Time To Live' (TTL)".

Now I have to

"In the MongoDB Compass UI, access the chatlogging EVENTS table and select the indexes tab; then, hit the DROP icon to the right of the TTL index."

But how can I do that without a UI?

I tried db.collection.dropIndex("chatlogging.EVENTS"), but there comes an error "ns not found" or "NamespaceNotFound"

Thanks for any help.

Sebastian

You know, that "collection" is a placeholder for the collection name you want to drop the index for?

the right command would be:

db.EVENTS.dropIndex("NameOfIndex")

To drop all indexes you can use:

Mongo 3.6:

db.EVENTS.dropIndex("*")

Mongo 4.2:

db.EVENTS.dropIndexes()

To get the name of the index you could run this command in before:

db.EVENTS.getIndexes()

Ah, thanks Torsten. As always: I can rely on you :)

You opened my eyes.

I now understand the syntax of the command :)

we can use the following commands on Mongo shell to drop the index:

> use chatlogging
> db.EVENTS.dropIndex("TimeStamp_1")

you can confirm the name of the index with the command "db.EVENTS.getIndexes()" - there should only be 1 based on timestamp - the "name" of that index is what is passed into the command above.

You can refer to documentation below for more information about these commands:

https://docs.mongodb.com/manual/reference/method/db.collection.dropIndex/

Hope this helps.

Make sure you have stopped the Community server and updated the TTL value in the chatlogging.ini before making the change to mongodb - the index will be recreated with the new TTL value after restart.

so order of steps -

a) stop community - update TTL value


b) in mongo shell - >

use chatlogging
db.EVENTS.getIndexes() - (confirms the name of the index - should be 'TimeStamp_1')
db.EVENTS.dropIndex( {"TimeStamp_1":1})

c) start community server.

d) You would then validate that the new TTL is in play by rechecking the value in the Index -

db.EVENTS.getIndexes()