This is sbt project for showing case for querying and sending data to elasticsearch using Akka-http and how to write unit tests.
Clone and run the unit test:
$ git clone git@github.com:techmonad/akka-http-elasticsearch.git
$ cd akka-http-elasticsearch
$ sbt test
i) Download the Elasticsearch 2.4.4 or latest version and unzip it.
ii) Run the following command.
$ bin/elasticsearch
$ sbt run
- Add the catalogue record
request:
$ curl -XPOST 'localhost:9000/catalogue/add' -d '{"id":1,"type":"book","author":"Martin Odersky","title":"Programming in Scala"}'
response:
Record added to catalogue successfully
- Search by query
request:
$ curl -XPOST 'localhost:9000/catalogue/search' -d '{"author":"martin"}'
response:
[{"id":2,"type":"book","author":"Martin Odersky","title":"Programming in Scala"}]