hngprojects / hng_boilerplate_python_fastapi_web

Apache License 2.0
154 stars 137 forks source link

feat: Added search queries functionality to fags #961

Closed theijhay closed 3 weeks ago

theijhay commented 3 weeks ago

Description

Added search functionality to the FAQ endpoint. The updated /faqs GET endpoint now allows filtering of FAQs based on a keyword provided by the user. The search checks both the question and answer fields for matches. If a keyword is provided, it returns the relevant FAQs; otherwise, it returns all FAQs.

Related Issue (Link to issue ticket)

Related Issue

Motivation and Context

This change was required to enhance the user experience by enabling more effective and accurate search functionality on the FAQ page. It allows users to quickly find relevant information by searching through both the questions and answers, ensuring that all relevant FAQs are returned based on the user’s query.

How Has This Been Tested?

The changes were tested using Postman by running the FastAPI application locally. The testing involved sending various GET requests to the /faqs endpoint with and without the keyword query parameter to ensure that the search functionality correctly filters FAQs based on the provided keyword. The tests confirmed that the search operates on both the question and answer fields, returns accurate results, and handles cases where no FAQs match the search criteria.

Screenshots (if appropriate - Postman, etc):

Screenshot from 2024-08-24 09-22-47

Types of changes

Checklist: