Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add search API functionality #2

Closed
wants to merge 10 commits into from
Closed

Add search API functionality #2

wants to merge 10 commits into from

Conversation

maxachis
Copy link

@maxachis maxachis commented May 7, 2024

Fixes

Description

Testing

  • TODO:

Performance

  • Performance impact expected to be limited -- Largest impact is likely to depend on how many search results are returned.

Docs

  • Incorporating Flask_restx enables documentation to be automatically generated from docstrings in Resource.
  • To view documentation -- start app.py and navigate to server location. Then click on "Default namespace" to view the full docuemtnation for all methods.
  • Namespace can be eventually configured, but is beyond the scope of this PR.

This update replaces flask_restful with flask_restx in the app.py file. Furthermore, Search has been imported from resources and a new API endpoint has been created, which takes in coarse_record_type and location as parameters. This change enhances search capabilities of the application.
Added a new SearchQueryEngine middleware in search_query.py file. This engine allows for complex SQL queries and provides functionality for search queries based on record type and location. A logging mechanism for query results is also included enhancing search auditing and debugging.
Implemented a new Search resource leveraging the SearchQueryEngine middleware for user-driven search inquiries. The resource processes search terms based on record type and location, and includes a reinitializing feature for failed queries. Search results auditing and error reporting are also handled.
The PsycopgResource has been updated to utilize the flask-restx library instead of flask_restful. Additionally, the __init__ method has been altered to accept positional arguments and explicitly invoke the superclass's initialization method.
Two major code blocks in Search.py were refactored for improved readability. Changes were made to simplify the invocation of the quick_search method in the classes and the formatting of the error message string.
The code in 'search_query.py' has been refactored for better readability and simplicity. Function 'expand_params' and class 'SearchQueryEngine' have been revised, simplifying function signatures, removing verbose comments, and improving SQL structure to enhance maintainability.
maxachis added 3 commits May 13, 2024 18:59
The search and lemmatization functions in the search_query.py middleware were refactored for enhanced readability and improved performance. The process_search_term function was split into two separate functions - lemmatize and search_query. This allows the functions to have narrower scope and better separation of concerns. A 'quick_search' function also better handles the distinction between unaltered and lemmatized results. Additionally, minor improvements were done in logging query results, mitigating potential issues in cases of empty search parameters.
@josh-chamberlain josh-chamberlain removed the request for review from mbodeantor May 18, 2024 01:46
@maxachis maxachis closed this Aug 16, 2024
@maxachis maxachis deleted the mc_search_v2_api branch August 16, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant