[#861] Remove 'metadata_modified' from if

Also, modify the default sort order if there is a search query to be
"score desc, metadata_modified"
[#861] Use the .get() function to look for 'q'