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

Allow multiple search terms in api full text search #95

Open
galbwe opened this issue Aug 25, 2021 · 0 comments · May be fixed by #220
Open

Allow multiple search terms in api full text search #95

galbwe opened this issue Aug 25, 2021 · 0 comments · May be fixed by #220
Assignees
Labels

Comments

@galbwe
Copy link
Collaborator

galbwe commented Aug 25, 2021

The api search parameter supports single word queries, but not multiple words.

Ex:

curl --location --request GET 'http://localhost:8000/leads?search=legal' --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluQGdtYWlsLmNvbSIsImV4cGlyZXMiOiIyMDIxLTA4LTI2VDAyOjQ2OjQyLjE2MzQ4MyswMDowMCIsImFkbWluIjp0cnVlfQ.NH5pOjfJ8f83XcYJmrJ3S-o2kkkbgmgX7C3R2mMHtBg'

returns 8 leads, but changing the search query parameter to veterans+legal

curl --location --request GET 'http://localhost:8000/leads?search=veterans+legal' --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluQGdtYWlsLmNvbSIsImV4cGlyZXMiOiIyMDIxLTA4LTI2VDAyOjQ2OjQyLjE2MzQ4MyswMDowMCIsImFkbWluIjp0cnVlfQ.NH5pOjfJ8f83XcYJmrJ3S-o2kkkbgmgX7C3R2mMHtBg'

returns a 500 error

Suggested approach

In leads.py, modify the _parse_search_param function to convert a + delimited string of search terms to a tsquery string. The input string will be returned by request.args.get("search").

For example, the string "veterans+legal" should be converted to the string "to_tsquery('veterans & legal')"

Once _parse_search_param returns the right query, modify the sql queries in the the _get_all_leads function to account for the changes to the search variable.

Resources

postgres documentation on full text search

@galbwe galbwe added the backend label Aug 25, 2021
@galbwe galbwe added the Hacktoberfest Hacktoberfest 2021 label Oct 1, 2021
@silkylaroux silkylaroux linked a pull request Oct 25, 2021 that will close this issue
10 tasks
@galbwe galbwe removed the Hacktoberfest Hacktoberfest 2021 label Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants