Example #1
0
        public int Index(Document doc, bool deleteold)
        {
            checkloaded();
            _log.Info("indexing doc : " + doc.FileName);
            DateTime dt = FastDateTime.Now;

            if (deleteold && doc.DocNumber > -1)
            {
                _deleted.Set(true, doc.DocNumber);
            }

            if (deleteold == true || doc.DocNumber == -1)
            {
                doc.DocNumber = _lastDocNum++;//新增编号
            }
            // save doc to disk
            //string dstr = fastJSON.JSON.ToJSON(doc, new fastJSON.JSONParameters { UseExtensions = false });//fastJSON
            string dstr = _json.SerializeObject(doc);

            //存储doc模型对象
            _docs.Set(doc.FileName.ToLower(), Encoding.Unicode.GetBytes(dstr));

            _log.Info("writing doc to disk (ms) = " + FastDateTime.Now.Subtract(dt).TotalMilliseconds);

            dt = FastDateTime.Now;
            // index doc
            AddtoIndex(doc.DocNumber, doc.Text);
            _log.Info("indexing time (ms) = " + FastDateTime.Now.Subtract(dt).TotalMilliseconds);

            return(_lastDocNum);
        }
Example #2
0
        internal bool Delete(T id)
        {
            // write a delete record
            int rec = (int)_archive.Delete(id);

            _deleted.Set(true, rec);
            return(_index.RemoveKey(id));
        }