Try ignoring the tags field in the “Search Drafts for” step, and just using the search text (showing “updated text” in your screenshot above). In particular look at the advanced query syntax you can use, it works in that field from Shortcuts (I just double checked it still does), and will give you a lot more control over how you search.
I think that you should be reviewing your tag utilisation for that. Rather than “john-smith”, you could have two tags “john” and “smith”, or nested tags “john/smith”.
With these, you could enter either just “john” in the case of fragmenting your tags, or “john/” in the case of nexting your tags.
For the first case, searching for “john” would find you someone who was named “John Smith”, and also find him with a search for “smith”. But, sometimes forenames are also valid surnames (“Neil”, “Morgan”, “Ryan”, etc.), so that might be something to consider.
For the second case, you would in effect have the forename as the root level tag, so searching for “john/” would only match fornames and not surnames (as they would be nested one level below the root). But, you would not be able to search for the last name “smith” without including the root/forname.
To search by full name, you would simply search for both tags in the first case (with AND logic), and in the second, you would search for the full nested tag - “john/smith”.
Each approach has that divergence on what is in and out based on the surname level, so it would simply be a preference to choose one, plus whatever other factors you might implement in management of your tags.
Partial Matching Tags
If you really had to do it without modifying your approach to tagging, then I would look at retrieving all tags from Drafts (you could use an action to compile them and return them to Shortcuts via the “Run action with text” step for Drafts in Shortcuts), looping through them to identify your partial matches (should “John” match to “Johnny Smith” for example?), and then putting those quries into your query string.
I would recommend the approach of revising your tagging system against trying to create partial matches against tags. Tags are there to help with categorisation for retrieval, but the set up looks to be hindering you (the proof is if you try to do this just in Draft’s built-in search functionality). Such hinderances are usually a sign that a modification to your tagging system is due, but I don’t know what other factors you might have to consider. Perhaps you have a common tagging approach across a half dozen systems, so the impact of changing it would be further reaching.
Ultimately, go with the most flexible and least friction approach you can get away with.
Here’s my solution for anyone coming across this thread in the future. I kept my kebab case tagging strategy, but implemented pretty much exactly what @sylumer suggested apart from that.
The shortcut works with multiple and partial tags as long as each partial tag is uniquely identified.
Note: That last restriction can be easily circumvented but works fine for my needs. It comes from exiting the loop over all existing tags after the first match in the Drafts Find First Matching Tag shortcut below. Instead, one could loop until the last match is found and return an array of all matches.
The shortcut is constructed in 4 steps:
A Drafts action Copy all Tags to Clipboard queries all existing Drafts tags across all Drafts and copied them to the clipboard.
A helper shortcut Drafts Get all Tags runs the Drafts action of step 1 and passes the clipboard to the next action.
A second helper shortcut Drafts Find First Matching Tag takes a single (partial) tag as input, iterates through the list of all tags, and returns the first full tag that contains the (partial) input tag.
The main shortcut Drafts Search Draft by Tag finds the corresponding full tag for each partial tag, prefixes each full tag with tag:, searches for any Draft that contains all the full tags, prompts the user with a list of these Drafts and finally opens the selected Draft in the app.
I will append screenshots of the individual steps below. Note that the shortcuts are not entirely reproducible from the images since I like modularity and have extracted some actions into more helper shortcuts
However, their implementation should be clear from the name and usually consists of just one or two actions. If there are questions left, feel free to ask them in this thread below!