hey @deanishe, thank you for your suggestion! i ended up already in my own implementation using a shellscript which uses mdfind internally.
in the end i did not check if there are no results, but append a "create" item all the time.
in case somebody wants to do something similar, my code is attached below.
cheers
#!/bin/bash
QUERY=${1}
DIRECTORY="/some/directory"
RESULTS=$(mdfind -onlyin "${DIRECTORY}" "kMDItemContentType == 'net.daringfireball.markdown' && (kMDItemDisplayName == '${QUERY}*'c || kMDItemTextContent == '${QUERY}*'c)")
SAVEIFS=${IFS}
IFS=$'\n'
RESULTS=($RESULTS) # Split Results
IFS=${SAVEIFS}
declare -a ITEMS
for i in "${RESULTS[@]:0:8}"; do
ITEM=$(cat << EOF
{
"uid": "${i}",
"type": "file",
"title": "$(echo ${i} | sed 's|.*/||')",
"subtitle": "${i}",
"arg": "${i}",
"icon": {
"type": "fileicon",
"path": "${i}"
}
},
EOF
)
ITEMS+=${ITEM}
done
ITEMS+=$(cat << EOF
{
"title": "Create '${QUERY}.md'",
"subtitle": "Create a new Vault entry",
"arg": "create:${QUERY}"
},
EOF
)
cat << EOF
{
"items": [${ITEMS}]
}
EOF