I am trying to create simple online library to learn more about Spring Boot and MongoDB. I wanted to create filter that uses one or more parametrs.
Like this: The customer list will be searchable by first name, last name, address, birth number. The user can search using one or more parameters. It will also be possible to sort by these attributes. All text searches will be functional from the specified three characters and can be any part of the text (in the infix, prefix or suffix of a string).
My questions:
1 - How can I create multi parameter filter? The only thing that comes to my mind is like this: In UserRepository:
public findByFirstNameAndLastNameAndAdressAndBirthNumber(String firstName, String lastName, String address Long birthNumber)
But it doesnt seem right to me.
2 - How can I make all of the parameters optional since user can search other users by one or more params?
3 - How should the endpoint for this request look like? Again, the only solution that comes to my mind is: http://localhost:8080/users/{firstName}/{lastName}/{address}/{birthNumber} -> but how can I handle the endpoint if only one of this parameters will be present?
4 - How to create filter that works with the metioned infix, prefix, ... ?