Correctly expand query with *#*

Closes openphacts/GLOBAL#183