{"id":17921079,"url":"https://github.com/kwang2049/easy-elasticsearch","last_synced_at":"2025-03-24T01:32:17.261Z","repository":{"id":57425066,"uuid":"365765674","full_name":"kwang2049/easy-elasticsearch","owner":"kwang2049","description":"Using business-level retrieval system (BM25) with Python in just a few lines.","archived":false,"fork":false,"pushed_at":"2023-02-03T14:38:10.000Z","size":39,"stargazers_count":31,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T02:38:27.595Z","etag":null,"topics":["bm25","docker","elasticsearch","information-retrieval"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kwang2049.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-09T13:57:24.000Z","updated_at":"2024-06-20T09:36:49.000Z","dependencies_parsed_at":"2023-02-18T07:50:41.606Z","dependency_job_id":null,"html_url":"https://github.com/kwang2049/easy-elasticsearch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwang2049%2Feasy-elasticsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwang2049%2Feasy-elasticsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwang2049%2Feasy-elasticsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwang2049%2Feasy-elasticsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kwang2049","download_url":"https://codeload.github.com/kwang2049/easy-elasticsearch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245194363,"owners_count":20575745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bm25","docker","elasticsearch","information-retrieval"],"created_at":"2024-10-28T20:30:30.402Z","updated_at":"2025-03-24T01:32:12.251Z","avatar_url":"https://github.com/kwang2049.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy Elasticsearch\n\nThis repository contains a high-level encapsulation for using [Elasticsearch](https://www.elastic.co/downloads/elasticsearch) with python in just a few lines.\n\n## Installation\nVia pip:\n```bash\npip install easy-elasticsearch\n```\nVia git repo:\n```bash\ngit clone https://github.com/kwang2049/easy-elasticsearch\npip install -e . \n```\n\n## Usage\nTo utilize the elasticsearch service, one can select from 3 ways:\n- (1) Start an ES service manually and then indicate the `host` and `port_http` (please refere to [download_and_run.sh](easy_elasticsearch/examples/download_and_run.sh)); \n- (2) Or leave `host=None` by default to start a docker container itself;\n- (3) Or leava `host=None` and setting `service_type=executable` to download an ES executable and start it in the back end.\n\nFinally, just either call its ```rank``` or ```score``` function for retrieval or calculating BM25 scores.\n```python\nfrom easy_elasticsearch import ElasticSearchBM25\n\npool = {\n    'id1': 'What is Python? Is it a programming language',\n    'id2': 'Which Python version is the best?',\n    'id3': 'Using easy-elasticsearch in Python is really convenient!'\n}\nbm25 = 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.\n\nquery = \"What is Python?\"\nrank = bm25.query(query, topk=10)  # topk should be \u003c= 10000\nscores = bm25.score(query, document_ids=['id2', 'id3'])\n\nprint(query, rank, scores)\nbm25.delete_index()  # delete the one-trial index named 'one_trial'\nbm25.delete_container()  # remove the docker container'\n```\nAnother example for retrieving Quora questions can be found in [easy_elasticsearch/examples/quora.py](easy_elasticsearch/examples/quora.py):\n```bash\npython -m easy_elasticsearch.examples.quora  --mode docker\n```\nor\n```bash\npython -m easy_elasticsearch.examples.quora  --mode executable\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwang2049%2Feasy-elasticsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkwang2049%2Feasy-elasticsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwang2049%2Feasy-elasticsearch/lists"}