title: Memory Based Full Text Search
body: <p>I have a social feature with a structure similar to a blog: posts and comments.</p>
  
  <p>Posts have a field called body, and so do comments. The posts and comments are stored in a SharePoint list, so direct SQL Full Text Queries are out.</p>
  
  <p>If someone types in "outage restoration efficiency in November", I really have no clue as to how I would properly return a list of posts based on the content of the posts and its attached comments.</p>
  
  <p>The good news is, there will never be more than 50-100 posts I need to search through at a time. Knowing that, the easiest way to solve this would be for me to load the posts and comments into memory and search through them via a loop.</p>
  
  <p>Ideally something like this would be the fastest solution:</p>
  
  <pre><code>class Post
  {
      public int Id;
      public string Body;
      public List&lt;Comment&gt; comments;
  }
  class Comment
  {
      public int Id;
      public int ParentCommentId;
      public int PostId;
      public string Body;
  }
  public List&lt;Post&gt; allPosts;
  public List&lt;Comment&gt; allComments;
  
  public List&lt;Post&gt; postsToInclude (string SearchText)
  {
      var returnList = new List&lt;Post&gt;();
      foreach(Post post in allPosts)
      {
          //check post.Body with bool isThisAMatch(SearchText, post.Body)
          //if post.Body is a good fit, returnList.add(post);
      }
      foreach(Comment comment in allComments)
      {
          //check post.Body with bool isThisAMatch(SearchText, comment.Body)
          //if comment.Body is a good fit, returnList.add(post where post.Id == comment.PostId);
      }
  }
  
  public bool isThisAMatch(string SearchText, string TextToSearch)
  {
      //return yes or no if TextToSearch is a good match to SearchText
  }
  </code></pre>