title: How to use Sharepoint Server Search (KeywordQuery class) to search through a sharepoint list?
body: <p>We have a requirement where users are to be allowed to search a list called "Reports" from the front-end, and advanced search, such as <code>author:"John Smith"</code> or <code>filetype:docx</code>, is to be supported.</p>
  
  <p>We decided that this can be achieved using <a href="http://msdn.microsoft.com/en-us/library/office/dn423226%28v=office.15%29.aspx#bk%5fQuerySOM" rel="nofollow">Sharepoint Server Search API</a> (using the <a href="http://msdn.microsoft.com/en-us/library/ee558911.aspx" rel="nofollow">Keyword Query Language</a>). Also, since it is possible that all users don't have access to all items in the list, we decided to go with the approach to use a web method with elevated privileges to query the list.</p>
  
  <p>This is my attempt so far... </p>
  
  <pre><code>public string GetSearchResults(string listname, string searchQuery)
  {
      SPUser superUser = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];
      using (SPSite site = new SPSite(SPContext.Current.Web.Url, superUser.UserToken))
      {
          KeywordQuery keywordQuery = new KeywordQuery(site);
          keywordQuery.QueryText = searchQuery;
  
          //where should listname be specified?
  
          SearchExecutor searchExecutor = new SearchExecutor(); 
          ResultTableCollection resultTableCollection = searchExecutor.ExecuteQuery(keywordQuery); 
          var resultTables = resultTableCollection.Filter("TableType", KnownTableTypes.RelevantResults); 
          ResultTable resultTable = resultTables.FirstOrDefault(); 
          DataTable dataTable = resultTable.Table; 
      }
  
      //how to parse result to filter only items in given list?
  }
  </code></pre>
  
  <p>...but what I don't understand is how to restrict search to only a given list or how to parse the search result to retrieve items of the list matching the search query.</p>
  
  <p>I'm new to Sharepoint search, so any pointers would help. </p>