We have a really exciting roadmap for Automation Tasks during Alfred 5 and into the future, including improved organisation and searching tasks, so stay tuned
This question belongs in the Workflow Help & Questions forum, where you will find the answer you seek stickied:
If you have any further questions about workflow variables, please ask in that thread or forum.
This is a simple script you can add to your Script Filters to replace "Alfred filters results" with a fuzzy search algorithm.
https://github.com/deanishe/alfred-fuzzy
How it works
Instead of calling your script directly, you call it via fuzzy.py, which caches your script's output for the duration of the user session (as long as the user is using your workflow), and filters the titles of the items emitted by your script against the user's query using a fuzzy algorithm.
Example usage
fuzzy.py only works in Script Filters, and you should run it as a bash/zsh script (i.e. with Language = /bin/bash or Language = /bin/zsh).
Instead of running your own script directly, place ./fuzzy.py in front of it.
For example, if your Script Filter script looks like this:
/usr/bin/python myscript.py
You would replace it with:
# export user query to `query` environment variable, so `fuzzy.py` can read it
export query="$1"
# or if you're using "with input as {query}"
# export query="{query}"
# call your original script via `fuzzy.py`
./fuzzy.py /usr/bin/python myscript.py
Note: Don't forget to turn off "Alfred filters results"!
Caveats
As the script is written in Python and uses a more complex matching algorithm, it can only handle a few thousands items at most before it becomes irritatingly sluggish (Alfred can handle many tens of thousands).
If there's interest in the script, I will rewrite it in a compiled language. My Go library uses the same algorithm, and it can comfortably handle 20K+ items.
You can grab a demo workflow from GitHub to see it in action.