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.1.tar.gz (31.0 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.1-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sedb-1.3.1.tar.gz
  • Upload date:
  • Size: 31.0 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.1.tar.gz
Algorithm Hash digest
SHA256 94a3cb15c8ce3de340a7260c1fbe1c2fd03bc00fb95c282189191a28f78ba990
MD5 33dfcaac306204f036600e1c792e1128
BLAKE2b-256 41dce96df05100f875976fc50b72c632f765236cacbc47827c049268e3b9ab98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sedb-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 36.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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 871f0743f26d98165cabc182082163ba2992b87b1455a78d9b584f94ca7ee8be
MD5 81982a4785f6c7f9c57d13164404eeca
BLAKE2b-256 468aa7e37bdbd98b8a9eaa6f8436fce091ca4ba47823d1a6763702ebbed5b0ee

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