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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sedb-1.3.tar.gz
  • Upload date:
  • Size: 28.8 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.tar.gz
Algorithm Hash digest
SHA256 695c739c0714d8926f9c1bf283947f4b73b7edd98b0d23366017c6926476a98c
MD5 a918ebd590c38e5aa09d96bacdc85f06
BLAKE2b-256 265ce4ee22ad173c83fd0861c238c83ad4092160acef497cdb9f6bd7e568c6f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sedb-1.3-py3-none-any.whl
  • Upload date:
  • Size: 34.4 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-py3-none-any.whl
Algorithm Hash digest
SHA256 5913a590fbf01f67380299fb2138f7beac664d990c3747efb2dc3f6e0ef80121
MD5 dfb068597aceaca2df156ce743a871ee
BLAKE2b-256 b02ec1a8e68253577cfc05020aa4f61885173a23a2579ad43cb4656404cea321

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