For reference here the search.rb file
https://github.com/discourse/discourse/blob/master/lib/search.rb
however you can easily find topics without tags using the data explorer plugin or you can even search topics without a specific tag using the not
operator, New search operator "not" for tags only