我在时间戳属性上构建了TTL索引,这是一个非常直接的索引。我使用MongoDb .Net驱动程序V2.7.2在mongo上下文构造函数中创建了索引。它按照预期从给定的集合中删除文档,但是“使用”不会在MongoDBCompass社区上更新,也不会在我通过Mongo终端进行检查时更新。
<code>
Here is the out put running $indexStat:
MongoDB Enterprise > db.testCollection.aggregate( [ { $indexStats: { } } ] ).pretty()
{
"name" : "_id_",
"key" : {
"_id" : 1
},
"host" : "****:27017",
"accesses" : {
"ops" : NumberLong(15),
"since" : ISODate("2018-12-20T22:52:01.132Z")
}
}
{
"name" : "****TTLIndex",
"key" : {
"Timestamp" : -1
},
"host" : "****:27017",
"accesses" : {
"**ops" : NumberLong(0),** <----- This is zero
"since" : ISODate("2018-12-20T22:52:01.132Z")
}
}
</code>

什么原因可能导致使用不更新?其他集合上的其他TTL索引是否正常工作?
编辑我期待看到这样的东西

发布于 2018-12-21 19:00:14
对于由用户请求驱动的索引访问,$indexStats中的$indexStats值只会增加。这不包括背景TTL的删除:
访问字段报告的统计信息仅包括由用户请求驱动的索引访问。它不包括内部操作,如通过TTL索引删除或块分割和迁移操作。
(https://docs.mongodb.com/manual/reference/operator/aggregation/indexStats/)
https://stackoverflow.com/questions/53887953
复制相似问题