Skip to content
Nicolas Dos Santos edited this page Jan 2, 2021 · 2 revisions

Spring Data Search

Spring Data Search

About

Spring Data Search allows to automatically expose endpoints in order to search for data related to JPA entities.

Spring Data Search provides an advanced search engine that does not require the creation of JPA repositories with custom methods needed to search on different fields of JPA entities.

We can search on any field, combine multiple criteria to refine the search, and even search on nested fields.

Query GIF

Why use Spring Data Search?

Spring Data Rest builds on top of the Spring Data repositories and automatically exports those as REST resources.

However, when we want to search for JPA entities according to different criteria, we need to define several methods in the Repositories to perform different searches.

Moreover, by default REST endpoints return JPA Entities content directly to the client, without mapping with a dedicated DTO class.
We can use Projections on Repositories, but this means that from the architecture level, we strongly associate the infrastructure layer with the application layer.

Spring Data Search allows to easily expose an endpoint for a JPA entity and thus be able to search on any fields of this entity, to combine several criteria and even search on fields belonging to sub-entities.

Let's say you manage Persons associated with Addresses, Vehicles and a Job.
You want to allow customers to search for them, regardless of the search criteria:

  • Search for Persons whose first name is "John" or "Jane"
  • Search for Persons whose company where they work is "Acme", and own a car or a motorbike
  • Search for Persons who live in London

You could create a Repository with custom methods to perform all these searches, and you could add new custom methods according to the needs.

Alternatively, you can use Spring Data Search which allows you to perform all these searches with a minimum configuration, without the need of a custom Repository. If you want to do other different searches, you do not need to add new methods to do that.

Documentation

Go to the Home Page.

Issues

Issues

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contact

Nicolas Dos Santos - @Kobee1203

Project Link: https://github.com/Kobee1203/spring-data-search

Social Networks

Tweets

GitHub forks GitHub stars GitHub watchers

License

MIT License
Copyright (c) 2020 Nicolas Dos Santos and other contributors