private MGRB ExecutionPlan(string filter, int maxsize) { //_log.Debug("query : " + filter); DateTime dt = FastDateTime.Now; // query indexes string[] words = filter.Split(' '); //bool defaulttoand = true; //if (filter.IndexOfAny(new char[] { '+', '-' }, 0) > 0) // defaulttoand = false; MGRB found = null;// MGRB.Fill(maxsize); foreach (string s in words) { int c; bool not = false; string word = s; if (s == "") { continue; } OPERATION op = OPERATION.AND; //if (defaulttoand) // op = OPERATION.AND; if (word.StartsWith("+")) { op = OPERATION.OR; word = s.Replace("+", ""); } if (word.StartsWith("-")) { op = OPERATION.ANDNOT; word = s.Replace("-", ""); not = true; if (found == null) // leading with - -> "-oak hill" { found = MGRB.Fill(maxsize); } } if (word.Contains("*") || word.Contains("?")) { MGRB wildbits = new MGRB(); // do wildcard search Regex reg = new Regex("^" + word.Replace("*", ".*").Replace("?", ".") + "$", RegexOptions.IgnoreCase); foreach (string key in _words.Keys()) { if (reg.IsMatch(key)) { _words.TryGetValue(key, out c); MGRB ba = _bitmaps.GetBitmap(c); wildbits = DoBitOperation(wildbits, ba, OPERATION.OR, maxsize); } } if (found == null) { found = wildbits; } else { if (not) // "-oak -*l" { found = found.AndNot(wildbits); } else if (op == OPERATION.AND) { found = found.And(wildbits); } else { found = found.Or(wildbits); } } } else if (_words.TryGetValue(word.ToLowerInvariant(), out c)) { // bits logic MGRB ba = _bitmaps.GetBitmap(c); found = DoBitOperation(found, ba, op, maxsize); } else if (op == OPERATION.AND) { found = new MGRB(); } } if (found == null) { return(new MGRB()); } // remove deleted docs MGRB ret; if (_docMode) { ret = found.AndNot(_deleted.GetBits()); } else { ret = found; } //_log.Debug("query time (ms) = " + FastDateTime.Now.Subtract(dt).TotalMilliseconds); return(ret); }