Now, I hope I have provided enough context and (hopefully) have restored my lost honour. Needless to say, that the foreach-found-remove approach works and yields the expected results. ![]() Moreover, it seems to screw mongo.Observe: C:\dev\poc\SDR>python FilterOoklaData.pyīad offset:0 accessing file: /data/db/ookla.0 - consider repairing database Can I do it with remove? Well, I have tried: (key, limit = group_size - max_group_size, sort=) It does accept query, but mine include sorting and limiting. Now, about the collection remove command. So, the last two steps are foreach-found-remove and this is the important detail of my question, that changes everything and I had to be more specific about it - sorry. Query the data by key, while sorting it ascending by the timestamp (the oldest first) and limiting the result to the count - max_group_size oldest recordsĪs you can see, this accomplishes the task of reducing the duplicates to at most N newest records.Iterate over all the pairs with count > max_group_size.So, what does it do? It reduces the number of duplicate keys to at most max_group_size per key value, leaving only the newest records. The specified field or fields cannot contain a null or an array value. If the id field is missing from a results document, MongoDB adds it automatically. Delete a Single Document To delete a single document, use db. query the original collection by the entry key, order it by test_date ascending, limit to the group size minus max_group_size.įor id in (key, limit = group_size - max_group_size, **deleteFindArgs): The aggregation results documents must contain the field(s) specified in the on, unless the on field is the id field. To remove all documents from a capped collection, use db.collection.drop() instead. Right now, I remove them manually, like this (using python): for id in mycoll.find(query, fields=): I have a query, which selects documents to be removed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |