Skip to content
Thibault-F edited this page Sep 2, 2019 · 2 revisions

Contributors Forks Stargazers Issues MIT License


Logo

Spring Search

Spring Search provides advanced search capabilities to a JPA entity
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

About The Project

Spring-search screenshot

Spring Search provides a simple query language to perform advanced searches for your JPA entities.

Let's say you manage cars, and you want to allow API consumers to search for:

  • Cars that are blue and that were created after year 2006 or whose model name contains "Vanquish"
  • Cars whose brand is "Aston Martin" or whose price is more than 10000$

You could either create custom repository methods for both these operations, which works well if you know in advance which fields users might want to perform searches on. You could also use spring-search that allows searching on all fields, combining logical operators and much more.

Please note that providing such a feature on your API does not come without risks such as performance issues and less clear capabilities for your API. This article summarizes these risks well.

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

  • npm
npm install npm@latest -g

Installation

  1. Clone the repo
git clone https:://github.com/sipios/spring-search.git
  1. Install NPM packages
npm install
  1. Make the library available
mvn install #inside the spring-search folder
  1. Add the repo to your project inside your pom.xml file
<dependency>
    <groupId>com.sipios</groupId>
    <artifactId>spring-search</artifactId>
    <version>0.0.4-SNAPSHOT</version>
</dependency>
  1. Import the library in your controller
import com.sipios.springsearch.anotation.SearchSpec;
  1. Use it (see Usage for various examples)
@GetMapping("someMapping")
fun yourFunctionNameHere(@SearchSpec specs: Specification<yourModelHere>): ResponseEntity<yourResponse> {
    return ResponseEntity(yourRepository.findAll(Specification.where(specs)), HttpStatus.OK)
}

Usage

Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources.

For more examples, please refer to the Documentation

Roadmap

See the open issues for a list of proposed features (and known 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

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Your Name - @sipios_fintech - [email protected]

Project Link: https://github.com/sipios/spring-search

Clone this wiki locally