Skip to content

suggest

ale23yfm edited this page Feb 15, 2025 · 2 revisions

/suggest/ endpoint in QA

/suggest/ endpoint in SWAGGER-UI

curl -X 'GET' \ 'http://peviitorqa.go.ro/api/v0/suggest/?q=<string>' \ -H 'accept: application/json'



Technical Documentation: Suggest Endpoint

Request and Response Structure

  • Method: GET

  • Endpoint name: /suggest

  • Request Parameters:

    • q – The search query string for which suggestions are requested (passed via query string).
  • Response Format: application/json; charset=utf-8

Expected Data Format

Query Parameters

?q=<string>

List of Status Codes and Error Messages

  • 200 OK – Request successful, returns list of companies and job counts if applicable.

  • 400 Bad Request – Invalid request parameters or missing required fields.

  • 401 Unauthorized – Authentication is required or invalid credentials.

  • 403 Forbidden – Access denied due to insufficient permissions.

  • 404 Not Found – The requested endpoint or resource does not exist.

  • 405 Method Not Allowed – Only GET requests are supported.

  • 500 Internal Server Error – An unexpected error occurred on the server.

  • 502 Bad Gateway – The primary and fallback servers are both unreachable.

  • 503 Service Unavailable – The SOLR server is down or unreachable.

  • 507 Insufficient Storage – SOLR or API server runs out of space/memory.

    {
      "error": "<message>",
      "code": "<number>"
    }
    

Business Logic Applied

  • Verifies the presence and validity of the q parameter.
  • Sends a request to the SOLR server’s suggest handler to retrieve job title suggestions.
  • Parses the SOLR response and extracts job title suggestions.
  • Returns the suggestions or an appropriate error message.

Security Measures

  • CORS policy: Open to all (Access-Control-Allow-Origin: *).
  • Rate Limits: Not specified but should be implemented for production.

Dependencies

  • SOLR Search Server – Required for fetching job title suggestions.
  • PHP file_get_contents function – Communicates with SOLR API.

Known Limitations & Edge Cases

  • SOLR Downtime: Returns 503 Service Unavailable if SOLR is unreachable.
  • Empty Query: Returns 400 Bad Request if q is missing.
  • Non-empty string: All fields must be non-empty.
  • No Suggestions: Returns a 200 response with a message if no suggestions are found.
  • Security Risks: No authentication currently implemented.
  • To do: Secure the endpoint using API keys.
  • To do: Protect against abuse.
  • To do: Add security.json and IP whitelisting.


Business Requirement Document: Job Title Suggestions Endpoint

Objective:

The objective of this project is to develop an API endpoint that provides job title suggestions based on a user's query. This endpoint will enhance user experience by helping users find relevant job titles quickly.

Key Requirements:

  1. Functionality:

    • The endpoint should accept a query string as input.
    • It should return a list of suggested job titles based on the query.
    • The suggestions should be retrieved from a SOLR suggester dictionary.
  2. Error Handling:

    • The endpoint should handle errors gracefully, providing meaningful error messages to users.
    • Specific error handling should include scenarios where no query is provided, the SOLR server is unavailable, or no suggestions are found.
  3. User Experience:

    • The endpoint should respond quickly to ensure a seamless user experience.
    • The response should include clear and relevant job title suggestions.
  4. Data Integrity:

    • Ensure that the suggestions are accurate and relevant to the query.
    • The endpoint should only return suggestions that are present in the SOLR suggester dictionary.
  5. Security:

    • Implement appropriate security measures to protect user data and prevent unauthorized access to the SOLR index.
  6. Scalability:

    • The endpoint should be designed to handle a high volume of requests without impacting performance.

Acceptance Criteria:

  • The endpoint successfully retrieves job title suggestions from the SOLR suggester dictionary.
  • The endpoint returns relevant suggestions based on the query.
  • Error messages are clear and informative for users.
  • The endpoint responds within an acceptable time frame.

Assumptions and Dependencies:

  • The SOLR index is properly configured with a suggester dictionary for job titles.
  • Necessary infrastructure and resources are available to support the endpoint.

Risks and Mitigation Strategies:

  • Risk: Technical issues with the SOLR index could prevent suggestion retrieval.

    • Mitigation: Regularly monitor the SOLR index for errors and perform maintenance as needed.
  • Risk: High traffic could impact performance.

    • Mitigation: Implement load balancing and optimize server resources to handle increased traffic.
  • Risk: Inaccurate suggestions could lead to poor user experience.

    • Mitigation: Regularly update and validate the suggester dictionary to ensure relevance and accuracy.

Clone this wiki locally