A flask blueprint providing an API for accessing and searching an ElasticSearch index created from source datapackages
Project description
apies
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:
-
Install Dependencies:
a. Install Docker locally
b. Install Python dependencies:
$ pip install dataflows datapackage-pipelines-elasticsearch $ pip install -e .
-
Go to the
sample/
directory -
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" }
-
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 } }
-
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)
-
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
Built Distribution
File details
Details for the file apies-0.0.21.tar.gz
.
File metadata
- Download URL: apies-0.0.21.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b7dda6f66cf5b4d9ee3832dfcdd851c8ef8cb40c4c3498e6dbbabde3cbf57c1 |
|
MD5 | 30baf5b06d7f115f4ee99ca6644b0658 |
|
BLAKE2b-256 | d9237d14d456770f06d58f726ca626d6280537dd1da3f2ee1d0c2917fa6d99a5 |
Provenance
File details
Details for the file apies-0.0.21-py2.py3-none-any.whl
.
File metadata
- Download URL: apies-0.0.21-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.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9da525702c61458f1e31e7d03d0da098021a472f9358d7d076ca339a98d4e00 |
|
MD5 | 8196920cbf72dadfb53d4cce5ff051aa |
|
BLAKE2b-256 | 1a1166af9096e5c7adbb866c194921049fbde65a09c37010fcd47e64b6c44d65 |