The following is a template for you to write custom queries against Apache Solr. It is documented in a way that resembles as much as possible how to write a SQL query.
Once you have set up Apache Solr Search module and connected a Solr server to Drupal, you can download the following file to the root of your Drupal site, adjust the query, and execute it with the following Drush command:
drush scr custom_solr_query.php