Skip to main content

Flask-ESearch

This is a Flask extension proving simple integration with Elasticsearch using python 3

Requirements

  1. Flask >= 1.XXX
  2. Elasticsearch>=6.4.6
  3. Python >= 3.8

How to use

  1. Install the package:

    pip install Flask-ESearch
    
  2. In your main app file:

    from datetime import datetime
    
    from flask import Flask, make_response
    from flask_esearch import ESearch
    
    app = Flask(__name__)
    
    # CREATE A ESearch CLIENT
    es = ESearch()
    es.init_app(app)
    
    
    @app.route('/')
    def hello_world():
        doc = {
            'author': 'kimchy',
            'text': 'Elasticsearch: cool. bonsai cool.',
            'timestamp': datetime.now(),
        }
        try:
            res = es.index(index="test-index", id=1, body=doc)
            return make_response(res['result'], 200)
        except Exception:
            res = es.get(index="test-index", id=1)
            return make_response(res['_source'], 200)
    
    
    app.run(debug=True, port=5001)
    

The above is an example of a Flask app integrating Flask-ESearch and an endpoint

  1. The instance allows to perform Elasticsearch queries. More info here.
  2. Testing access http://127.0.0.1:5001/.
    1. If is the first access, will show Created or else the record inserted

Custom Settings

In order to add your elasticsearch settings, the package allows to change those 2 properties and override them in your settings file.

Name Type Default Value
ELASTICSEARCH_HOST string localhost:9200
ELASTICSEARCH_HTTP_AUTH string None

Metadata

Release files for Flask-ESearch 0.5.0

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

Source distribution (sdist)

Source distribution for Flask-ESearch 0.5.0
File Size Uploaded
Flask-ESearch-0.5.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Flask-ESearch 0.5.0
File Interpreter ABI Platform
Flask_ESearch-0.5.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 9.1 kB

Release files / Flask-ESearch-0.5.0.tar.gz

Download URL Flask-ESearch-0.5.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
22c2b20d0841ff39ff7ff491df6d361753297d42c2f6aae5f97364664663cb71
BLAKE2b-256 checksum
How to use checksums
d624cfe706d4a8fef7163dbd9a6b30f82d0230538074400163d8386f3576063c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Release files / Flask_ESearch-0.5.0-py2.py3-none-any.whl

Download URL Flask_ESearch-0.5.0-py2.py3-none-any.whl
Size 4.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5006825d23576e4bb5e9ef6d56b389ecf5bd8c29fb1d8e23843b6e752eaadd5b
BLAKE2b-256 checksum
How to use checksums
77183ec9ab10aece4f610efc5eafc83683c4cce9ceb4dceec4b90b57208df939
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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