It is very easy to create a rest service. We even do not need a servlet container to run the application. Spring Boot will prepare a container for us. We only need to add what is necessary. Even a web.xml file is not necessary.
This rest service searches a text in elasticsearch and returns the result as JSON. Amount of code needed for this task is amazingly low.
First class is the controller. Request will be served with this controller. For elasticsearch repository see [1].
Now comes the spring boot application entry point.
In order to use the rest service use the request like this:
http://localhost:8080/recipe/by-name?name=mynameis
For complete code listing in github see [2].
1. Spring Boot Elasticsearch Application
2. Github - essync
This rest service searches a text in elasticsearch and returns the result as JSON. Amount of code needed for this task is amazingly low.
First class is the controller. Request will be served with this controller. For elasticsearch repository see [1].
Now comes the spring boot application entry point.
In order to use the rest service use the request like this:
http://localhost:8080/recipe/by-name?name=mynameis
For complete code listing in github see [2].
1. Spring Boot Elasticsearch Application
2. Github - essync
Comments
Post a Comment