Skip to main content

Search Engine DataBase utils

Project description

sedb

Search Engine DataBase utils

Install

pip install sedb[common] --upgrade

Currently, sedb supports interacting with following services:

  • common:

    • MongoDB
    • ElasticSearch
    • Redis
    • RocksDB
  • vector:

    • Faiss
    • Milvus
    • Qdrant

You can install all dependencies by:

pip install sedb[all] --upgrade

or default extreme light-weight dependencies by:

pip install sedb --upgrade

Usage

Run example:

python example.py

See: example.py

from tclogger import logger, logstr, get_now_str, dict_to_str

from sedb import MongoOperator, MongoConfigsType
from sedb import RocksOperator, RocksConfigsType
from sedb import filter_str_to_params, filters_str_to_mongo_filter
from sedb import MongoDocsGenerator


def test_rocks():
    rocks_configs: RocksConfigsType = {"db_path": "z.rkdb"}
    rocks = RocksOperator(configs=rocks_configs)
    rocks.db.put("now", get_now_str())
    print("  * now:", rocks.db.key_may_exist("now"), rocks.db.get("now"))


def test_filter_str_to_params(filters_str: str):
    filter_strs = filters_str.split(";")
    for filter_str in filter_strs:
        logger.note(f"* filter_str: {logstr.mesg(filter_str)}")
        filter_params = filter_str_to_params(filter_str)
        logger.okay(dict_to_str(filter_params, add_quotes=True), indent=2)


def test_filters_str_to_mongo_filter(filters_str: str):
    logger.note(f"filters_str: {logstr.mesg(filters_str)}")
    mongo_filter = filters_str_to_mongo_filter(filters_str)
    logger.okay(dict_to_str(mongo_filter, add_quotes=True), indent=2)


def test_mongo_generator():
    generator = MongoDocsGenerator()
    generator.init_all_with_cli_args()
    for docs_batch in generator.docs_batch_generator():
        for doc in docs_batch:
            logger.mesg(doc)
    # python example.py -H localhost -P 27017 -D <DBNAME> -c <COLLECTION> -i pubdate -s 2025-10-06 -x "u:stat.view>1k" -fi "title,pubdate,stat.view" -m 5 -b 1000


if __name__ == "__main__":
    # test_rocks()
    # filters_str = "d:pubdate<=2012-01-01;insert_at=[2024-12-01,2024-07-01];u:stat.view>1kw;index_at=[2023-01-01,None]"
    # test_filter_str_to_params(filters_str)
    # test_filters_str_to_mongo_filter(filters_str)
    test_mongo_generator()

    # python example.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sedb-1.3.2.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sedb-1.3.2-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file sedb-1.3.2.tar.gz.

File metadata

  • Download URL: sedb-1.3.2.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for sedb-1.3.2.tar.gz
Algorithm Hash digest
SHA256 93f80720155b135d3a31cb68d86685ee2bf2026e51c10eacac50eee74c00afa3
MD5 ba993cc609b736ab9fc31b850072dbce
BLAKE2b-256 b3a097af06f19bccfae404d36db78170598222c351f021ec269a66fd685e3d59

See more details on using hashes here.

File details

Details for the file sedb-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: sedb-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 38.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for sedb-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f4729002f556502c83e24e58253e6a753efe10a7f6905d5199656908470e068f
MD5 63e9c6651e1a14adf4000ae6acfcb783
BLAKE2b-256 c812daaa71048404ca7e2e59baab87edce0a6c64fb45b44a186798b24fd555a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page