title: How do you debug your Nest queries?
body: <p>I'm new to Nest, and I very likely am not creating my query like I think I am.  My question is more along the lines of teach a man to fish rather than give me a fish.  However, I'll use my current problem as an example.</p>
  
  <p>I have several documents in ElasticSearch of the type <code>Series</code>.  I'll stub it out below without the attributes and public modifiers with just the information pertinent to the query:</p>
  
  <pre><code>class Series
  {
      string Id {get; set;}
      DateTime StartDate {get; set;}
      DateTime EndDate {get; set;}
      HashSet&lt;Role&gt; ReleasableTo {get; set;}
  }
  </code></pre>
  
  <p>These are all fine and dandy.  I can <code>Get()</code> a <code>Series</code> object no problem.  The problem I'm running into is trying to figure out how Nest is formatting my query.  My immediate goal is to find the most recent <code>Series</code> that is releasable to <code>Role.Visitor</code>.  I set up the Nest query like this:</p>
  
  <pre><code>ISearchResponse&lt;Series&gt; response = client
      .Search&lt;Series&gt;(r =&gt; 
           r.Filter(f =&gt; 
               f.Term&lt;Role&gt;(t=&gt;t.ReleasableTo.First(), Role.Visitor))
      .SortDescending(ser =&gt; ser.EndDate).Size(1));
  </code></pre>
  
  <p>In my mind, this should be producing a query that filters the Series so it only considers the ones that are <code>ReleasableTo</code> my <code>Role.Visitor</code>, reverse sorts by end date, and limits the results to one returned.  That would be exactly what I want.  In the multiple thousands of records I have for Series, about 90% fit this profile.  Unfortunately the query returns 0 results.  There is no error, just no results.  What I don't know is if I'm using the API incorrectly, if Nest is producing a query structure that doesn't make sense, or I simply don't know ElasticSearch well enough.  When I remove the <code>Filter</code> clause I get a result, but I'm not guaranteed everyone is allowed to see it.</p>
  
  <p>How do I view the JSON that Nest produces and sends to ElasticSearch?</p>