Easy Elasticsearch
This repository contains a high-level encapsulation for using Elasticsearch with python in just a few lines.
Installation
Via pip:
pip install easy-elasticsearch
Via git repo:
git clone https://github.com/kwang2049/easy-elasticsearch
pip install -e .
Usage
To utilize the elasticsearch service, one can select from 3 ways:
- (1) Start an ES service manually and then indicate the
hostandport_http(please refere to download_and_run.sh); - (2) Or leave
host=Noneby default to start a docker container itself; - (3) Or leava
host=Noneand settingservice_type=executableto download an ES executable and start it in the back end.
Finally, just either call its rank or score function for retrieval or calculating BM25 scores.
from easy_elasticsearch import ElasticSearchBM25
pool = {
'id1': 'What is Python? Is it a programming language',
'id2': 'Which Python version is the best?',
'id3': 'Using easy-elasticsearch in Python is really convenient!'
}
bm25 = ElasticSearchBM25(pool, port_http='9222', port_tcp='9333') # By default, when `host=None` and `mode="docker"`, a ES docker container will be started at localhost.
query = "What is Python?"
rank = bm25.query(query, topk=10) # topk should be <= 10000
scores = bm25.score(query, document_ids=['id2', 'id3'])
print(query, rank, scores)
bm25.delete_index() # delete the one-trial index named 'one_trial'
bm25.delete_container() # remove the docker container'
Another example for retrieving Quora questions can be found in easy_elasticsearch/examples/quora.py:
python -m easy_elasticsearch.examples.quora --mode docker
or
python -m easy_elasticsearch.examples.quora --mode executable
Metadata
Release files for easy-elasticsearch 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| easy-elasticsearch-0.0.9.tar.gz | 10.7 kB | Without provenance | Details for easy-elasticsearch-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| easy_elasticsearch-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for easy_elasticsearch-0.0.9-py3-none-any.whl |
Total release size: 23.0 kB
Release files / easy-elasticsearch-0.0.9.tar.gz
| Download URL | easy-elasticsearch-0.0.9.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca2d2691bf7384b6047d15f7ea02cab4b6578d89c813f5a4195a58e7bc555396
|
|
BLAKE2b-256 checksum How to use checksums |
69eb9c70a27c9c96178e1b10c4f414dcb90d3b2da6527ed1698d6d070d993586
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13
|
Release files / easy_elasticsearch-0.0.9-py3-none-any.whl
| Download URL | easy_elasticsearch-0.0.9-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20254e02f3d111b45aa1a147126f80e57211f16b42e1b34fc1805e6b53ea605b
|
|
BLAKE2b-256 checksum How to use checksums |
b8ecc2061288ebe2a85289862c353acb6d87d64f1288afbde9014b097835f877
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13
|
Security for easy-elasticsearch 0.0.9
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.