When using the search form, we always perform an ILIKE search with the wildcards on both sides:
|
if form_data.get("last_name"): |
|
officer_query = officer_query.filter( |
|
Officer.last_name.ilike(f"%%{form_data['last_name']}%%") |
|
) |
|
if form_data.get("first_name"): |
|
officer_query = officer_query.filter( |
|
Officer.first_name.ilike(f"%%{form_data['first_name']}%%") |
|
) |
However, there are cases where we know the first few or last few letters of an officer's name given what we can see of their badge. Any searches we do now search for the term's presence in the entire word, which makes it difficult to be specific with the search text.
It would be nice to add the capacity to do an exact search if a user supplies a wildcard value. For instance, sh would search throughout the field, but sh* would require the term at the beginning of the word and *sh would require the term at the end of the word.
When using the search form, we always perform an
ILIKEsearch with the wildcards on both sides:OpenOversight/OpenOversight/app/utils/forms.py
Lines 278 to 285 in 3c90393
However, there are cases where we know the first few or last few letters of an officer's name given what we can see of their badge. Any searches we do now search for the term's presence in the entire word, which makes it difficult to be specific with the search text.
It would be nice to add the capacity to do an exact search if a user supplies a wildcard value. For instance,
shwould search throughout the field, butsh*would require the term at the beginning of the word and*shwould require the term at the end of the word.