Skip to main content

exec_es

exec_es 对ElasticSearch进行了二次开发,针对多开发环境数据写入,以及bulk进行了优化。

Installation

1.使用python包管理工具 pip 进行安装。

pip install exec-es

Usage

from execelasticsearch import ExecES, ClientConfig, MappingMethod

# MappingData.SearchBody.update will change defult Search Body Template, use before ExecES init.
MappingMethod.SearchBody.update('match', 'match', {"<<field>>": {"query": "<<value>>"}})

dt_config = ClientConfig(hosts=[{'host': "172.28.0.1"}])
dp_config = ClientConfig(hosts=[{'host': "172.28.0.2"}], doc_type='your_tags')
es_clients = ExecES(dt=dt_config, dp=dp_config)

index = 'exec_es_test'
hosts = ["dt", "dp"]


def es_create(data_, dex=0):
    data_ = data_[dex]
    print(es_clients.create(index, data_['id'], data_, hosts))


def es_update(data_, dex=0):
    data_ = data_[dex]
    data_['account_score'] = 10
    print(es_clients.update(index, data_['id'], data_, hosts))


def es_delete(id_):
    print(es_clients.delete(index, id_, hosts))


def es_update_or_ignore(data_, dex=0):
    data_ = data_[dex]
    print(es_clients.update_or_ignore(index, data_['id'], data_, hosts))


def es_upsert(data_, dex=0):
    data_ = data_[dex]
    print(es_clients.upsert(index, data_['id'], data_, hosts))


def es_bulk_upsert(data_):
    data_[0]['account_score'] = 10
    print(es_clients.bulk_upsert(index, data_, hosts))


def es_bulk_delete(data_):
    ids = [i['id'] for i in data_]
    print(es_clients.bulk_delete(index, ids, hosts))


def es_mget(data_, _source_includes=None):
    ids = [i['id'] for i in data_]
    print(es_clients.mget(index, ids, hosts, _source_includes=_source_includes))


def es_exists(ids: list):
    print(es_clients.exists_ids(index, ids, hosts))


search_b = es_clients.search_body
search_b.update(body_type1={"query": {"bool": {"must": {"exists": {"field": "<<field>>"}}}}})
search_b["body_type2"] = {"query": {"bool": {"must": {"exists": {"field": "<<field>>"}}}}}
print(search_b.body_type_list)  # show default body_type list


def es_search(body_kwargs: dict = None):
    res = es_clients.search(index, body_kwargs or {'match': dict(field='id', value=1)}, 'dt')
    for i in res:
        print(i)


def es_original_func():
    print(es_clients['dt'].ping())


if __name__ == '__main__':
    es_original_func()

Contributing

使用前请做适当的测试,以确定跟您的项目完全兼容。

License

MIT

Metadata

Release files for exec-es 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exec-es 0.0.11
File Size Uploaded Provenance Actions
exec-es-0.0.11.tar.gz 8.7 kB Without provenance Details for exec-es-0.0.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for exec-es 0.0.11
File Interpreter ABI Platform Actions
exec_es-0.0.11-py3-none-any.whl Python 3 none any Details for exec_es-0.0.11-py3-none-any.whl

Total release size: 15.0 kB

Release files / exec-es-0.0.11.tar.gz

Download URL exec-es-0.0.11.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9e4d593c38d21821972d83d67fc65b6da336e0e94b1cf75c61614f7ed01a3bca
BLAKE2b-256 checksum
How to use checksums
18c1817617036167a10534c8c67a3d1432fe4a9a84a9ff76578dea04e4ce832f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / exec_es-0.0.11-py3-none-any.whl

Download URL exec_es-0.0.11-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5065e221a263692bd476acfb3478f75369a66a1eea64a97184f2ee5041f3ba4c
BLAKE2b-256 checksum
How to use checksums
c0298aea3c6967b2925adc672e661a20fda51e3cf964f1fce78c312beb9a37de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Security for exec-es 0.0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page