title: Sunspot Rails to order search results by model id?
body: <p>Assume that I have the following model and I have made it searchable with <code>sunspot_rails</code>.</p>
  
  <pre><code>class Case &lt; ActiveRecord::Base
    searchable do
    end
  end
  </code></pre>
  
  <p>Standard <code>schema.xml</code> of Sunspot in Rails declare <code>id</code> as an indexed field. When I use the web interface to access solr and test queries a query like:</p>
  
  <pre><code>http://localhost:8982/solr/select/?q=id%3A%22Case+15%22&amp;version=2.2&amp;start=0&amp;rows=10&amp;indent=on
  </code></pre>
  
  <p>which searches for <code>Cases</code> with <code>id</code> equal to <code>Case 15</code> works fine and returns results.</p>
  
  <p>The problem is when I carry out the search with Sunspot Rails in the rails console:</p>
  
  <pre><code>s = Case.search do 
      keywords('id:"Case 15"')
  end
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>=&gt; &lt;Sunspot::Search:{:fl=&gt;"* score", :rows=&gt;10, :start=&gt;0, :q="id:\"Case 15\"", :defType=&gt;"dismax", :fq=&gt;["type:Case"]}&gt;
  </code></pre>
  
  <p>which show that it correctly puts in <code>:q</code> the correct query value, but the hits are 0:</p>
  
  <pre><code>s.hits
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>=&gt; []
  </code></pre>
  
  <p>If we assume that <code>keywords</code> is not equivalent and only searches the <code>text</code> field (full-text search) and not the field defined before the colon <code>:</code>, then I can try the following:</p>
  
  <pre><code>s = Case.search do
    with(:id, "Case 15")
  end
  </code></pre>
  
  <p>but this fails with a Sunspot exception:</p>
  
  <pre><code>Sunspot::UnrecognizedFieldError: No field configured for Case with name 'id'
  </code></pre>
  
  <p>How can I search using the indexed standard solr/sunspot <code>id</code> field of my model?</p>
  
  <p>And to make the question more useful, how can I order by the id. The following does not work:</p>
  
  <pre><code>s = Case.search do
    keywords("xxxx")
    order_by :id, :desc
  end
  </code></pre>
  
  <p>does not work. <code>Sunspot::UnrecognizedFieldError: No field configured for Case with name 'id'</code></p>