Vita-App / Vita

Bringing life back to your college life.
https://mentorship.thapar.edu/
MIT License
120 stars 78 forks source link

Add Text-Search Support on Mentor Collection #14

Closed Rishabh-malhotraa closed 2 years ago

Rishabh-malhotraa commented 2 years ago

Use FTS-search provided by MongoDB to search a mentor by name company, year of graduation, etc.

image
parthn2 commented 2 years ago

Hey Can I work on this ?

Rishabh-malhotraa commented 2 years ago

Hey Can I work on this ?

Sure, that would be great!

Also don't forget to add debouncing to the text field in the front end.

As for mock data you need to create a Mongo db database with name Vita and uncomment the fake-data endpoint in the routes folder and visit that end point to add data, or you can just copy the code written in that file and run that script using node

parthn2 commented 2 years ago

Mentor cards are not coming when running on local machine, Is there any issue?

Rishabh-malhotraa commented 2 years ago

You need to download mongo db community server and mongodb compass, create a Collections called Vita

  1. Uncomment these lines https://github.com/Rishabh-malhotraa/Vita/blob/main/api/src/routes/apiRoutes.ts#L27-L28
  2. Run the server npm run dev
  3. go to endpoint https://localhost:5000/api/data on chrome URL
  4. go to endpoint https://localhost:5000/api/topicData
Rishabh-malhotraa commented 2 years ago

@parthn2 I have included the exported dump files of the data, so you could just follow this guide here

parthn2 commented 2 years ago

@parthn2 I have included the exported dump files of the data, so you could just follow this guide here

I am working on mac. So, the 3rd step(PATH) was different and So I tried with some article but still getting error. Mongo is installed in my system I am getting this error: Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused So, by trying to solve this I got one more issue and so on after that i tried to start the process from the start. I tried to delete the files and some were deleted and some not so I am not able to install again and it is messed up 😔

Rishabh-malhotraa commented 2 years ago

Make sure that you have MongoDB server is running before trying to connect to the database

 brew services start mongodb-community

You can read more here

parthn2 commented 2 years ago

Finally Got done with the setup, would start the work now 😀 You can add this video as reference for mac setup. It was very helpful. https://www.youtube.com/watch?v=MzdhVBBFsdI

Rishabh-malhotraa commented 2 years ago

Great! I'll add the link to the installation guide for mac users.

Gurdeep475 commented 2 years ago

I would like to work on this issue under GSSOC`22. Please assign it to me.

Rishabh-malhotraa commented 2 years ago

Hello, this is not an easy issue. Would you like to tell me how you plan to solve this issue, before assigning it to you. Thank you!

Gurdeep475 commented 2 years ago

My plan is to define a text index on the Mentor model, which will allow text search on documents, I assume to receive a string from the client, and the search will be performed, and matching docs will be returned.

Rishabh-malhotraa commented 2 years ago

@Gurdeep475 perfect, that's what required.

You can set up with database with the mock data that are provided.

Let's break the Task into two-part, first, let's make the backend API for it, and then we would incorporate it with the frontend-- I would like to add debouncing and autosuggestion/completion on the frontend once we have the API built

Gurdeep475 commented 2 years ago

database setup is ready, what's the next step?

Gurdeep475 commented 2 years ago

and please assign this issue to me under GSSOC`22.

Rishabh-malhotraa commented 2 years ago
  1. create a text index on the mentor model

  2. you create API endpoint /fts?metorSearchText=text

  3. you do a Full-text Search by extracting text from the query parameter mentorSearchText field and then return all the mentors in JSON format.

    [
    ...mentorsRetrievedfromDatatbase
    ]
  4. Don't think about the front-end right now. Just think about making the API and validate your API-endpoint using postman to check if you get a proper response back.

Extra

  1. Make FTS fuzzy; that is, if the user searches gogle, we should still return mentor whose company matches google
  2. Add unit test to make sure the endpoint works properly
  3. Add a CI/CD script to run test before deployment
Gurdeep475 commented 2 years ago

@Rishabh-malhotraa I would like to discuss the weights for the fields for the FTS search. I have included the following relevant fields: first_name, last_name, job_title, company, description, expertise, language. which field according to you should have more weight?

Rishabh-malhotraa commented 2 years ago

@Gurdeep475, I don't really have an opinion on it; what do you think is the best way to go about this?

Gurdeep475 commented 2 years ago

I think expertise should have highest weight, followed by job title, company, description, rest fields will be given 1 weight.

Gurdeep475 commented 2 years ago

@Rishabh-malhotraa I have done most of the work but need guidance on Unit Test and CI-CD script part.

MaitriDA commented 2 years ago

Can you please assign me thi issue under GSSOC'22

Rishabh-malhotraa commented 2 years ago

I think expertise should have highest weight, followed by job title, company, description, rest fields will be given 1 weight.

I like this, but can you code it in a way so that we can change the weights later on.

I would like to test the API with some test cases to see how well it works with different weights?

We can leave the unit test, for now, try testing it manually by making requests through postman and checking if you are getting the correct response, after that, we will formally write some unite tests using jest

You can see these videos to get an idea of what CI/CD Pipelines are

https://www.youtube.com/watch?v=scEDHsr3APg

https://www.youtube.com/watch?v=eB0nUzAI7M8

https://www.youtube.com/watch?v=X3F3El_yvFg

Rishabh-malhotraa commented 2 years ago

Can you please assign me thi issue under GSSOC'22

Hey @MaitriDA it's been worked on by @Gurdeep475 do you mind working on something else thanks.

Gurdeep475 commented 2 years ago

I like this, but can you code it in a way so that we can change the weights later on.

  1. Yes using Model.syncIndexes() method, while connecting to DB, will update the text index.
Gurdeep475 commented 2 years ago

Manually Tested the API, the response looks good to me. image

Rishabh-malhotraa commented 2 years ago

Manually Tested the API, the response looks good to me. image

Looks good to mee too

I really want to make sure we write a unit test for this too. Would you like to do it, or should I create an issue so someone else can complete it once this PR gets Merged.

For backend end mocha/jasmine work better than jest which is more focused for front end testing

Mocha and Jasmine are stronger for testing the back end because they were initially built for Node applications; therefore, they have more back-end tools and documentation available than Jest.

Gurdeep475 commented 2 years ago

I really want to make sure we write a unit test for this too. Would you like to do it, or should I create an issue so someone else can complete it once this PR gets Merged

I would let you tonight before 12:AM.

Gurdeep475 commented 2 years ago

I will mark the PR final, regarding unit testing and CI/CD you can make a separate issue.