{"id":18048048,"url":"https://github.com/ivangfr/springboot-elasticsearch-thymeleaf","last_synced_at":"2025-10-06T23:57:10.732Z","repository":{"id":41528463,"uuid":"146220783","full_name":"ivangfr/springboot-elasticsearch-thymeleaf","owner":"ivangfr","description":"The goal of this project is to implement an application called product-app. It consists of two Spring Boot services: product-api (backend) and product-ui (frontend). Data will be stored in Elasticsearch","archived":false,"fork":false,"pushed_at":"2024-12-21T21:42:16.000Z","size":14105,"stargazers_count":15,"open_issues_count":0,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T08:42:24.903Z","etag":null,"topics":["elasticsearch","http-interface","java","jib","spring-boot","spring-data-elasticsearch","spring-web-mvc","springdoc-openapi","thymeleaf"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivangfr.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"ivangfr"}},"created_at":"2018-08-26T22:22:41.000Z","updated_at":"2024-12-30T11:49:59.000Z","dependencies_parsed_at":"2024-08-17T07:55:51.608Z","dependency_job_id":null,"html_url":"https://github.com/ivangfr/springboot-elasticsearch-thymeleaf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspringboot-elasticsearch-thymeleaf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspringboot-elasticsearch-thymeleaf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspringboot-elasticsearch-thymeleaf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspringboot-elasticsearch-thymeleaf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivangfr","download_url":"https://codeload.github.com/ivangfr/springboot-elasticsearch-thymeleaf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248196641,"owners_count":21063472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elasticsearch","http-interface","java","jib","spring-boot","spring-data-elasticsearch","spring-web-mvc","springdoc-openapi","thymeleaf"],"created_at":"2024-10-30T20:11:05.270Z","updated_at":"2025-10-06T23:57:10.711Z","avatar_url":"https://github.com/ivangfr.png","language":"Java","funding_links":["https://github.com/sponsors/ivangfr"],"categories":[],"sub_categories":[],"readme":"= springboot-elasticsearch-thymeleaf\n\nThe goal of this project is to implement an application called `product-app`. It consists of two https://docs.spring.io/spring-boot/index.html[`Spring Boot`] services: `product-api` (backend) and `product-ui` (frontend). The data will be stored in https://www.elastic.co/elasticsearch[`Elasticsearch`].\n\n== Proof-of-Concepts \u0026 Articles\n\nOn https://ivangfr.github.io[ivangfr.github.io], I have compiled my Proof-of-Concepts (PoCs) and articles. You can easily search for the technology you are interested in by using the filter. Who knows, perhaps I have already implemented a PoC or written an article about what you are looking for.\n\n== Project diagram\n\nimage::documentation/project-diagram.jpeg[]\n\n== Applications\n\n* **product-api**\n+\n`Spring Boot` Web Java application that exposes a REST API to manage products. Product information is stored in `Elasticsearch`. `product-api` uses https://docs.spring.io/spring-data/elasticsearch/reference/[`Spring Data Elasticsearch`] to persist/query/delete data in `Elasticsearch`.\n\n* **product-ui**\n+\n`Spring Boot` Web application that was implemented using https://www.thymeleaf.org/[`Thymeleaf`] as HTML template. Also, it uses https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-http-interface[`Http Interfaces`] to simplify HTTP remote access to `product-api`.\n\n== Prerequisites\n\n* https://www.oracle.com/java/technologies/downloads/#java21[`Java 21`] or higher;\n* A containerization tool (e.g., https://www.docker.com[`Docker`], https://podman.io[`Podman`], etc.)\n\n== Start Environment\n\n* Open a terminal and navigate to the `springboot-elasticsearch-thymeleaf` root folder run:\n+\n[,bash]\n----\ndocker compose up -d\n----\n\n* Wait for `Elasticsearch` Docker container to be up and running. To verify it, run:\n+\n[,bash]\n----\ndocker ps -a\n----\n\n== Initialize Elasticsearch\n\nNOTE: In the following steps, we will create an index, an alias and do a reindex using pre-defined scripts. In case you prefer to do it step-by-step calling `Elasticsearch` API, refer to link:create-index-alias-reindex.adoc[Creating indexes, alias and reindexing using Elasticsearch API].\n\n* In a terminal, make sure you are in the `springboot-elasticsearch-thymeleaf` root folder;\n\n* Run the following script to create the index `ecommerce.products.v1` with the alias `ecommerce.products` (you can use the default values by just pressing `Enter` on every user input):\n+\n[,bash]\n----\n./create-index.sh\n----\n\n* If you want to insert some products, run:\n+\n[,bash]\n----\n./insert-products.sh\n----\n\n* If you want to fix the `reference` property mapping error (explained below), run:\n+\n[,bash]\n----\n./reindex.sh\n----\n+\nThe script `./reindex.sh` is used to reindex one index to another. The default will reindex from `ecommerce.products.v1` to `ecommerce.products.v2`. The only difference between `elasticsearch/mapping-v1.json` (used by `ecommerce.products.v1`) and `elasticsearch/mapping-v2.json` (used by `ecommerce.products.v2`) is the `type` of the `reference` property. In the former, it is set the type `text` and, in the latter, the type `keyword`.\n+\nIt's interesting because the `reference` property has some special characters. An example of `reference` code is `SBES@DDR4-10000`. As it has the type `text`, `Elasticsearch` (using the `standard` analyzer) splits the content in tokens ['SBES', 'DDR4', 10000]. So, for example, if you are looking for a product with `DDR4` RAM and, for some reason, the string `DDR4` is present in the reference code of some product X, the product X will be selected, even if it doesn't have `DDR4` in its description.\n+\nSo, the script `./reindex.sh` aims to fix it, setting the type `keyword` to the `reference` property. The `DDR4` search issue won't happen again because, from now on, `Elasticsearch` won't tokenize the content present in the `reference` property.\n\n== Running applications using Maven\n\nBelow are the steps to start and run the applications using `Maven`. We will need to open a terminal for each one. Make sure you are in the `springboot-elasticsearch-thymeleaf` root folder while running the commands.\n\n* **product-api**\n+\n[,bash]\n----\n./mvnw clean spring-boot:run --projects product-api\n----\n\n* **product-ui**\n+\n[,bash]\n----\n./mvnw clean spring-boot:run --projects product-ui -Dspring-boot.run.jvmArguments=\"-Dserver.port=9080\"\n----\n\n== Running applications as Docker containers\n\n* Build Docker Images\n** In a terminal, make sure you are in the `springboot-elasticsearch-thymeleaf` root folder;\n** Run the following script:\n+\n[,bash]\n----\n./build-docker-images.sh\n----\n\n* Environment Variables\n\n** **product-api**\n+\n|===\n|Environment Variable |Description\n\n|`ELASTICSEARCH_URIS`\n|Specify uris of the `Elasticsearch` search engine to use (default `localhost:9200`)\n\n|===\n\n** **product-ui**\n+\n|===\n|Environment Variable |Description\n\n|`PRODUCT_API_URL`\n|Specify url of the `product-api` service to use (default `http://localhost:8080`)\n\n|===\n\n* Run Docker containers\n** In a terminal, make sure you are in the `springboot-elasticsearch-thymeleaf` root folder;\n** Run the following script:\n+\n[,bash]\n----\n./start-apps.sh\n----\n\n== Application's URL\n\n|===\n|Application |URL\n\n|product-api\n|http://localhost:8080/swagger-ui.html\n\n|product-ui\n|http://localhost:9080\n|===\n\n== Demo\n\n* Below is a simple demo showing a user interacting with `product-ui`:\n+\nimage::documentation/demo-user-interaction.gif[]\n\n== Shutdown\n\n* To stop applications:\n** If they were started with `Maven`, go to `product-api` and `product-ui` terminals and press `Ctrl+C`;\n** If they were started as Docker containers, go to a terminal and, inside the `springboot-elasticsearch-thymeleaf` root folder, run the script below:\n+\n[,bash]\n----\n./stop-apps.sh\n----\n* To stop and remove docker compose containers, network and volumes, go to a terminal and, inside the `springboot-elasticsearch-thymeleaf` root folder, run the following command:\n+\n[,bash]\n----\ndocker compose down -v\n----\n\n== Cleanup\n\nTo remove the Docker images created by this project, go to a terminal and, inside the `springboot-elasticsearch-thymeleaf` root folder, run the script below:\n[,bash]\n----\n./remove-docker-images.sh\n----\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangfr%2Fspringboot-elasticsearch-thymeleaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivangfr%2Fspringboot-elasticsearch-thymeleaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangfr%2Fspringboot-elasticsearch-thymeleaf/lists"}