REST APPLICATION FOR USER CONSULTATION USING FLS (FULL TEXT SEARCH).
Perform
$ docker -vto check the installation.
Clone the repository ( $ git clone [email protected]:gustavo-flor/find-user-service.git );
Visit the cloned folder ( $ cd find-user-service )? ️;
Run the application build ( $ ./mvnw clean install -DskipTests=true );
Climb the service and its dependencies ( $ docker compose up );
We are ready to use the application through endpoint http://localhost:8080/search ?
Access the "production" environment to test the application.
It is important to note that it is not a dedicated host, so lentidons or limitations of refukes are expected. In the first access a delay may occur for response.
GET | /search?query={terms} | json
Users who were found based on the terms sent, ordered according to users' relevance and compatibility with the terms.
TERMS : Each word separated by a space is considers a term (if there is a need to use to search for a specific sentence just send the sentence between double quotes)
Examples:
query=Pedro Gabriel : The application will look for users that contemplate the term "Peter" or "Gabriel" (or its derivatives, I explain this better in the topic of "details + goals ...");
query="Pedro Gabriel" : the application will seek users who contemplate exactly the term "Pedro Gabriel";
query="Pedro" Gabriel : The application will seek users who contemplate exactly the term "Peter" or contemplate "Gabriel" (or their derivatives).
| Parameter | Description | Mandatory |
|---|---|---|
| query | Terms for search. | Yes |
| From | Page, page count starts at 0. Standard value: 0. | No |
| size | Users limit per page. Standard value: 15. | No |
| debug | Adds to users' return to the relevance and compatibility note with the terms sent. Standard value: false, permitted values [true, false]. | No |
Example:
$ curl http://localhost:8080/search ? query=%22pedra%22 {
"from" : 0 ,
"size" : 15 ,
"data" : [
{
"id" : "9f64853b-f164-4b13-a3d7-1fdb9977e516" ,
"name" : "Jeferson Pedra" ,
"username" : "jeferson.pedra"
} ,
{
"id" : "b4026e35-932c-4943-b0db-7dd31eca5597" ,
"name" : "Stefane Pedra Zimiani" ,
"username" : "stefane.pedra.zimiani"
}
]
}User Return with
debug: true
{
"textScore" : 1.5 ,
"id" : "482c46f3-a27c-4f1a-abd0-3039ede21fdd" ,
"name" : "Gustav Berghahn" ,
"username" : "gustav.berghahn" ,
"relevance" : 3
} The need was to build a scalable and high performance application that could seek through one or more users of a particular database and order them according to their relevance. Knowing this was chosen to create a Spring + Mongodb application.
We do not have an endpoint to include new users, they are included when climbing the application based on the files present in the Java Project
resourcesfolder.
What were the motivations for the use of spring?
First and most important is familiarity with the framework, but also the ease of creating and configuring an API REST with it, as well as facilitating configuration with MongodB and other deploy (Heroku) platforms.
What were the motivations for the use of MongoDB?
Knowing our need, we can realize that we will not have to deal with any relationship within our database, so that would be a great reason, but the main reason I can not lie: P was your text search feature ... FTS Tadããã !!!
Advantages and disadvantages of Full Text Search ...
By indexing the search texts for the search, FTS ends up bringing a lot of performance compared to options such as "Like", this solution specializes in search for terms, so often can perform the search much more right and more quickly.
Its biggest disadvantage and enemy is: fts is not a "like", and at first it is difficult to understand this, we cannot send half of a term and believe that search will work as we expect.
Knowing this for an even more right search, it is ideal to really know all the possibilities that the FTS gives us through its documentation.
Repository with a web application to consume this service, Find-USER-WEB [under development].
Feel free to create improvements for this solution ⚗, big hug!