Skip to main content

A flask blueprint providing an API for accessing and searching an ElasticSearch index created from source datapackages

Project description

apies

Travis Coveralls PyPI - Python Version

apies is a flask blueprint providing an API for accessing and searching an ElasticSearch index created from source datapackages.

endpoints

TBD

configuration

Flask configuration for this blueprint:

    from apies import apies_blueprint
    import elasticsearch

    app.register_blueprint(
        apies_blueprint(['path/to/datapackage.json', Package(), ...],
                        elasticsearch.Elasticsearch(...), 
                        'index-to-search-in', 
                        document_doctype='document',
                        dont_highlight=['fields', 'not.to', 'highlight']),
        url_prefix='/search/'
    )

local development

You can start a local development server by following these steps:

  1. Install Dependencies:

    a. Install Docker locally

    b. Install Python dependencies:

    $ pip install dataflows datapackage-pipelines-elasticsearch
    
  2. Go to the sample/ directory

  3. Start ElasticSearch locally:

    $ ./start_elasticsearch.sh
    

    This script will wait and poll the server until it's up and running. You can test it yourself by running:

    $ curl -s http://localhost:9200
     {
         "name" : "DTsRT6T",
         "cluster_name" : "elasticsearch",
         "cluster_uuid" : "QnLVHaOYTkmJZzkCG3Hong",
         "version" : {
             "number" : "5.5.2",
             "build_hash" : "b2f0c09",
             "build_date" : "2017-08-14T12:33:14.154Z",
             "build_snapshot" : false,
             "lucene_version" : "6.6.0"
         },
         "tagline" : "You Know, for Search"
     }
    
  4. Load data into the database

    $ python load_fixtures.py
    

    You can test that data was loaded:

    $ curl -s http://localhost:9200/jobs/_count?pretty
     {
         "count" : 3516,
         "_shards" : {
                 "total" : 5,
                 "successful" : 5,
                 "failed" : 0
         }
     }
    
  5. Start the sample server

    $ python server.py 
     * Serving Flask app "server" (lazy loading)
     * Environment: production
     WARNING: Do not use the development server in a production environment.
     Use a production WSGI server instead.
     * Debug mode: off
     * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
    
  6. Now you can hit the server's endpoints, for example:

         $ curl -s 'localhost:5000/api/search/jobs?q=engineering&size=2' | jq
         127.0.0.1 - - [26/Jun/2019 10:45:31] "GET /api/search/jobs?q=engineering&size=2 HTTP/1.1" 200 -
         {
             "search_counts": {
                 "_current": {
                 "total_overall": 617
                 }
             },
             "search_results": [
                 {
                 "score": 18.812,
                 "source": {
                     "# Of Positions": "5",
                     "Additional Information": "TO BE APPOINTED TO ANY CIVIL <em>ENGINEERING</em> POSITION IN BRIDGES, CANDIDATES MUST POSSESS ONE YEAR OF CIVIL <em>ENGINEERING</em> EXPERIENCE IN BRIDGE DESIGN, BRIDGE CONSTRUCTION, BRIDGE MAINTENANCE OR BRIDGE INSPECTION.",
                     "Agency": "DEPARTMENT OF TRANSPORTATION",
                     "Business Title": "Civil Engineer 2",
                     "Civil Service Title": "CIVIL ENGINEER",
                     "Division/Work Unit": "<em>Engineering</em> Review & Support",
             ...
         }
    

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apies-0.0.18.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

apies-0.0.18-py2.py3-none-any.whl (9.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file apies-0.0.18.tar.gz.

File metadata

  • Download URL: apies-0.0.18.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for apies-0.0.18.tar.gz
Algorithm Hash digest
SHA256 0b2d7dc9103d4aadee3f9d6c75a9d0bdbd858c2360084597c98a0dd6aff63e68
MD5 b129d7c66f7092359a5b985bf05e97f6
BLAKE2b-256 c2477d4d1912a91d6d78d1eaa78c47c72d47eb05d121b501f0a7c2e4dd032498

See more details on using hashes here.

Provenance

File details

Details for the file apies-0.0.18-py2.py3-none-any.whl.

File metadata

  • Download URL: apies-0.0.18-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for apies-0.0.18-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b252552ec5b9da105aa8179948c0224d63345cfd3c887559be7037ab2786d164
MD5 cb4162cefc7a04684c86bf2664c2e555
BLAKE2b-256 bd6966f79fb45d34546c44a4b8e7dd52b5de989b2a887b0829e8df080aa74441

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page