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.2.tar.gz (25.9 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.2-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sedb-1.2.tar.gz
Algorithm Hash digest
SHA256 0597bba588f23bb1806e24315db2bb3d2e3f07c14285725b76acb30b9cc0c7ff
MD5 e4dacff4a806c1324926d578afb0ff8b
BLAKE2b-256 a08a4006cbf581b57ce32bfb05463180c6ee195b51b297d592f5ab46ba09d1b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sedb-1.2-py3-none-any.whl
  • Upload date:
  • Size: 31.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f8bd9434de8508cf704fd92150bf421ec2f194289684c4070720626502e48872
MD5 33beca7907ac4baf8fb746b32e562a6f
BLAKE2b-256 acc111f7427203a3fc4614159c8832a1c4980aad766fbd5f065bc0b009477a45

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