Beispiel #1
0
 //--- Constructors ---
 public SearchQuery(string raw, string processed, LuceneClauseBuilder constraint, IEnumerable <QueryTerm> terms)
 {
     if (constraint == null)
     {
         throw new ArgumentException("constraint");
     }
     Raw = raw;
     if (string.IsNullOrEmpty(processed))
     {
         LuceneQuery = constraint.Clause;
     }
     else if (constraint.IsEmpty)
     {
         LuceneQuery = processed;
     }
     else
     {
         var query = new LuceneClauseBuilder();
         query.And("(" + processed + ")");
         query.And(constraint.Clause);
         LuceneQuery = query.Clause;
     }
     Terms     = terms == null ? new QueryTerm[0] : terms.ToArray();
     Cacheable = !_userTypeRegex.IsMatch(LuceneQuery);
 }
 //--- Constructors ---
 public SearchQuery(string raw, string processed, LuceneClauseBuilder constraint, IEnumerable<QueryTerm> terms) {
     if(constraint == null) {
         throw new ArgumentException("constraint");
     }
     Raw = raw;
     if(string.IsNullOrEmpty(processed)) {
         LuceneQuery = constraint.Clause;
     } else if(constraint.IsEmpty) {
         LuceneQuery = processed;
     } else {
         var query = new LuceneClauseBuilder();
         query.And("(" + processed + ")");
         query.And(constraint.Clause);
         LuceneQuery = query.Clause;
     }
     Terms = terms == null ? new QueryTerm[0] : terms.ToArray();
 }
 public static string ToClause(this string clause) {
     var c = new LuceneClauseBuilder();
     c.And(clause);
     return c.Clause;
 }
 public void Constraints_are_ANDed_to_Query() {
     var constraint = new LuceneClauseBuilder();
     constraint.And("constraint");
     var query = new SearchQuery("raw", "cooked", constraint, null);
     Assert.AreEqual(string.Format("+(cooked) {0}",constraint.Clause),query.LuceneQuery);
 }