Search API '/u/search and wild cards or features?

AI-generated summary

The Discourse search API /u/search does not support wildcards or partial matches within names. alank is attempting to use the API to search for users with a partial match, but is only getting exact matches. For example, searching for “an” only returns “andrew”, not “marian” or “mark”. sam explains that the search uses full text search and does not support partial matches efficiently without using trigrams, which would require scanning a large table with potentially millions of rows.

I’m attempting to use the Discourse search via /u/search/… and unless I’m mistaken it doesn’t offer wildcards or defaults to partial matches within names, for example I have the following users…

*andrew
*marian
*mark

If I search on 'an" I only get ‘andrew’
If I search on 'ma" I get both ‘mark’ and ‘marian’

Are there any wild-card features to find on a search of ‘an’ to both get ‘andrew’ and ‘marian’ ?

My full query in JS is…

this.DiscourseAPI.get(`u/search/users.json?term=${term}&include_groups=false&include_mentionable_groups=false&include_messageable_groups=false&topic_allowed_users=false`

Where {term} is replaces by the user search string (eg. ‘an’ or ‘ma’)

We would need trigrams do do that efficiently, at the moment we use full text search.

The restriction is in place cause we don’t want to scan a table with potentially millions of rows.