All Projects → Idnan → go-mongo-indexer

Idnan / go-mongo-indexer

Licence: other
CLI tool to manage mongo database collection indexes through json files

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to go-mongo-indexer

pg analyse
Tools to gather useful information from PostgreSQL
Stars: ✭ 19 (-20.83%)
Mutual labels:  indexes
tzindex
Tezos Blockchain Indexer
Stars: ✭ 64 (+166.67%)
Mutual labels:  indexer
bcdhub
Better Call Dev backend
Stars: ✭ 30 (+25%)
Mutual labels:  indexer
eyy-indexer
An image and video friendly directory indexer for web directories.
Stars: ✭ 53 (+120.83%)
Mutual labels:  indexer
codechain-indexer
A blockchain data indexing tool for CodeChain
Stars: ✭ 21 (-12.5%)
Mutual labels:  indexer
das account indexer
DEPRECATED, please use https://github.com/dotbitHQ/das-account-indexer
Stars: ✭ 22 (-8.33%)
Mutual labels:  indexer
Jackett
API Support for your favorite torrent trackers
Stars: ✭ 6,690 (+27775%)
Mutual labels:  indexer
ETH-transactions-storage
Indexer for Ethereum to get transaction list by ETH address
Stars: ✭ 155 (+545.83%)
Mutual labels:  indexer
DocDex
JSON API & Discord Bot for Javadocs
Stars: ✭ 31 (+29.17%)
Mutual labels:  indexer
libDrive
libDrive is a Google Drive media library manager and indexer, similar to Plex, that organizes Google Drive media to offer an intuitive and user-friendly experience.
Stars: ✭ 14 (-41.67%)
Mutual labels:  indexer
Intelligent Document Finder
Document Search Engine Tool
Stars: ✭ 45 (+87.5%)
Mutual labels:  indexer
Minixed
A minimal but nice-looking PHP directory indexer.
Stars: ✭ 135 (+462.5%)
Mutual labels:  indexer
Storm
Simple and powerful toolkit for BoltDB
Stars: ✭ 1,814 (+7458.33%)
Mutual labels:  indexes
pg reindex
Console utility for gracefully rebuild indexes/pkeys for PostgreSQL, with minimal locking in semi-auto mode.
Stars: ✭ 20 (-16.67%)
Mutual labels:  indexes

go-mongo-indexer

CLI utility to manage mongodb collection indexes

Blog URL Build Status Go Report Card

Usage

indexer --config <index-config-file> 
        --uri <mongodb-connection-uri>
        --database <database name>
        --apply

Details of options is listed below

Option Required? Description
config Yes Path to indexes configuration file
uri Yes MongoDB connection string e.g. mongodb://127.0.0.1:27017
database Yes Database name
apply No Whether to apply the indexes on collections or not. If not given, it will show the plan that will be applied

Config Format

The configuration file is just a simple json file containing the indexes to be applied. This file is an array of objects. Where each object has details like collection name, cap size and indexes for this specific collection.

[
    {
        "collection": "order",     // name of collection
        "cap": null,               // Number of bytes 
        "index": [                 // Array of index details
            {"cartId": 1},         // An ascending order index
            {"status": -1},        // Descending order index
            {"orderId": 1},
            {"groupId": 1},
            {"currency": 1},
            {"createdAt": -1},
            {"orderNumber": 1, "type": 1},  // Composite index on orderNumber and type
            {"type": -1, "paymentStatus": -1, "payment.paymentMethod": -1}
        ]
    },
    {
        "collection": "collection_name",
        "cap": null,
        "index": [
            {"userId": -1},
            {"username": 1},
            {"orderId": 1, "_unique": 1},                       // creates a `unique index`
            {"createdAt": -1, "_expireAfterSeconds": 500}       // creates a `expires index` that will delete document after given number of seconds 
        ]
    }
    ....
    ....
    ....
]

Note capping is still progress not yet supported

Examples

See list of index changes before applying

indexer --config "/path/to/xyz.json" --uri "mongodb://127.0.0.1:27017/database_name" --database "database_name"

Apply the index changes

$ indexer --config "/path/to/xyz.json" --uri "mongodb://127.0.0.1:27017/database_name"  --database "database_name" --apply

Todo

  • Write tests
  • Collection capping
  • Support for _unique and _expireAfterSeconds indexes

Contributing

Anyone is welcome to contribute, however, if you decide to get involved, please take a moment to review the guidelines:

  • Only one feature or change per pull request
  • Write meaningful commit messages
  • Follow the existing coding standards

License

MIT © Adnan Ahmed

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].