switzersc / api-in-a-box Goto Github PK
View Code? Open in Web Editor NEWSimple API solution with Docker, ElasticSearch, and Sinatra
Simple API solution with Docker, ElasticSearch, and Sinatra
It would be great to spin up the hypermedia API using a datapackage.json
rather than a CSV (or multiple CSV locations).
We'd love to do this for the Illinois Legal Aid Online resource directory, which is available as datapackage and CSV resources here.
For more info on datapackes, see: https://frictionlessdata.io/specs/data-package/
Is this that work you referenced? Slick and so valuable. Thx!
Or should we just use the /resources
URL and enable it to accept the search queries?
When I make a request to /resources/search
with no params, I should either get no items back or the first page of non-queried items. Instead, I get this error:
Stretcher::RequestError: Error processing request (400)! get URL: http://elastic:9200/api/_search
Resp Body: {"error"=>{"root_cause"=>[{"type"=>"query_parsing_exception", "reason"=>"[match] query malformed, no field", "index"=>"api", "line"=>1, "col"=>20}], "type"=>"search_phase_execution_exception", "reason"=>"all shards failed", "phase"=>"query", "grouped"=>true, "failed_shards"=>[{"shard"=>0, "index"=>"api", "node"=>"9MLFr-XJSdG4rOGbpoJJ6w", "reason"=>{"type"=>"query_parsing_exception", "reason"=>"[match] query malformed, no field", "index"=>"api", "line"=>1, "col"=>20}}]}, "status"=>400}
/usr/local/bundle/gems/stretcher-1.21.1/lib/stretcher/server.rb:250:in `check_response'
/usr/local/bundle/gems/stretcher-1.21.1/lib/stretcher/server.rb:227:in `block in request'
/usr/local/bundle/gems/stretcher-1.21.1/lib/stretcher/server.rb:225:in `synchronize'
/usr/local/bundle/gems/stretcher-1.21.1/lib/stretcher/server.rb:225:in `request'
/usr/local/bundle/gems/stretcher-1.21.1/lib/stretcher/es_component.rb:31:in `request'
/usr/local/bundle/gems/stretcher-1.21.1/lib/stretcher/es_component.rb:18:in `do_search'
/usr/local/bundle/gems/stretcher-1.21.1/lib/stretcher/index.rb:138:in `search'
/api/api.rb:28:in `block in <class:ApiInABox>'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
/usr/local/bundle/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/nulllogger.rb:9:in `call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/head.rb:13:in `call'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
/usr/local/bundle/gems/rack-cors-0.4.0/lib/rack/cors.rb:80:in `call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/tempfile_reaper.rb:15:in `call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/lint.rb:49:in `_call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/lint.rb:37:in `call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/showexceptions.rb:24:in `call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/commonlogger.rb:33:in `call'
/usr/local/bundle/gems/sinatra-1.4.5/lib/sinatra/base.rb:217:in `call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/chunked.rb:54:in `call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/content_length.rb:15:in `call'
/usr/local/bundle/gems/rack-1.6.0/lib/rack/handler/webrick.rb:89:in `service'
/usr/local/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/usr/local/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/usr/local/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
Hey @switzersc,
It was amazing to listen to your talk at Gluecon last week. Thank you for sharing this brilliant "small data" idea.
We spoke briefly after your talk about you possibly writing a blog post about your use of Elasticsearch in this project. If you are still up for this, we'd love to post it on https://elastic.co/blog. Just shoot me an email at shaunak [at] elastic.co.
Thanks,
Shaunak
Make sure this can work with CSVs hosted on Airtable
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.