title: How to specify Lucene.net boolean AND, OR , not operator from normal and, or and not variables?
body: <p>In my project i was implementing a full text index search using Lucence. But while doing this i was stuck up with a logic of differentiating Lucene boolean operators from Normal and, or , not words.</p>
  
  <p>Suppose for example if we are searching for <strong>"I want a pen and pencil"</strong> , but by default Lucene.net searching Lucene OR operation. so it will search like <strong>"I OR want OR a OR pen OR pencil"</strong> not like what i would like to have like <strong>"I OR want OR a OR pen OR and OR pencil"</strong>. So how come we differentiate a normal and, or, not from Lucene operators?</p>
  
  <p>For this I have done a helper method which looks like</p>
  
  <pre><code>/// &lt;summary&gt;
      /// Method to get search predicates
      /// &lt;/summary&gt;
      /// &lt;param name="searchTerm"&gt;Search term&lt;/param&gt;
      /// &lt;returns&gt;List of predicates&lt;/returns&gt;
      public static IList&lt;string&gt; GetPredicates(string searchTerm)
      {
          //// Remove unwanted characters
          //searchTerm = Regex.Replace(searchTerm, "[&lt;(.|\n)*?!'`&gt;]", string.Empty);
          string exactSearchTerm = string.Empty,
                 keywordOrSearchTerm = string.Empty, 
                 andSearchTerm = string.Empty, 
                 notSearchTerm = string.Empty,
                 searchTermWithOutKeywords = string.Empty;
          //// Exact search tern
          exactSearchTerm = "\"" + searchTerm.Trim() + "\"";
          //// Search term without keywords
          searchTermWithOutKeywords = Regex.Replace(
              searchTerm, " and not | and | or ", " ", RegexOptions.IgnoreCase);
          //// Splioted keywords
          string[] splittedKeywords = searchTermWithOutKeywords.Trim().Split(
              new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
          //// Or search term
          keywordOrSearchTerm = string.Join(" OR ", splittedKeywords);
          //// And search term
          andSearchTerm = string.Join(" AND ", splittedKeywords);
          //// not search term
          int index = 0;
          List&lt;string&gt; searchTerms = (from term in Regex.Split(
                                          searchTerm, " and not ", RegexOptions.IgnoreCase)
                                          where index++ != 0
                                          select term).ToList();
          searchTerms = (from term in searchTerms
                 select Regex.IsMatch(term, " and | or ", RegexOptions.IgnoreCase) ?
                 Regex.Split(term, " and | or ", RegexOptions.IgnoreCase).FirstOrDefault() : 
                 term).ToList();
          notSearchTerm = searchTerms.Count &gt; 0 ? string.Join(" , ", searchTerms) : "\"\"";
          return new List&lt;string&gt; { exactSearchTerm, andSearchTerm, keywordOrSearchTerm, notSearchTerm };
      }
  </code></pre>
  
  <p>but it will return four results. so i have to loop through my index for 4 times , but it seems to be very hectic one. so can anybody give a hand to resolve this one in a single loop?</p>