Giter Club home page Giter Club logo

vinayakmp007 / simple-java-database-elastic-springboot Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 199 KB

This is a small example of using SQL database along with ElasticSearch.So SQL database can be used to store relations and other information while ElasticSearch can be used for searching data effectively.This project shows how to synchronize data in database to ElasticSearch in near realtime.

License: MIT License

Dockerfile 0.07% Java 99.78% Shell 0.15%
elasticsearch elasticsearch-high-level-client spring-boot jpa mysql-database docker docker-compose java

simple-java-database-elastic-springboot's Introduction

simple-java-database-elastic-springboot

This is a small example of using SQL database along with ElasticSearch.So SQL database can be used to store relations and other information while ElasticSearch can be used for searching data effectively.This project shows how to synchronize data in database to ElasticSearch in near realtime.

Prerequisite

  • Maven
  • JDK
  • Docker
  • Docker Compose

Steps

  1. Clone the Project
  2. Execute run.sh

Working

  • Synchronizing data to ElasticSearch
    • The synchronizing data to elastic search is done by three tasks
      1. Full Index
        • It takes all non deleted items from the sql database to elastic search.It is normally executed one time when the application is deployed.
      2. Periodic Update
        • It moves all the documents that were updated after the last was Periodic Update executed.This helps in syncing changes made to data in database not through the application.It is scheduled periodically.
      3. Instant Update
        • The Changes made to sql database usning application is immediately updated in the Elastic Search also.
  • Executing jobs
    • Indexing documents to Elastic search is done by tasks.Initially these task requests are populated in database where application instances peridocally poll.The instances will lock some tasks and execute it.
  • Rest End point
    • The CRUD operations uses SQL Database while searching and highlighting of entity uses elastic search.

Examples

Application instances are exposed in port 8081 and 8082

  • Create curl -X POST http://localhost:8081/suggestion -i -d '{"suggestion":"Test this" }' -H "Content-Type: application/json";

  • Update curl -X PUT http://localhost:8081/suggestion/1 -i -d '{"suggestion":"Test this" }' -H "Content-Type: application/json";

  • Retrieve curl -X GET http://localhost:8081/suggestion/1 -i -H "Content-Type: application/json";

  • Delete curl -X DELETE http://localhost:8081/suggestion/1 -i -d '{"suggestion":"Test this" }' -H "Content-Type: application/json";

  • Search curl -X POST http://localhost:8081/suggestion/_search -i -d '{ "query":{"operation":"search","search":"string to be searched","field":"suggestion" ,"highlight":true }}' -H "Content-Type: application/json";

simple-java-database-elastic-springboot's People

Contributors

vinayakmp007 avatar shivanth avatar dependabot[bot] avatar

Stargazers

Anatoliy Korsakov avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.