/// <summary>
        /// Load data directly from lucene document
        /// </summary>
        /// <param name="doc"></param>
        public SbSearchDoc(Lucene.Net.Documents.Document doc)
        {
            ContentTypes = doc.GetValues("type");
            Sources = doc.GetValues("source");
            Categories = doc.GetValues("category");

            try {
                LastModified = DateTimeEx.FromUnixTimestamp(Convert.ToInt32(doc.Get("lastmod")));
            } catch { LastModified = DateTime.MinValue; }

            Title = doc.Get("title");
            Keywords = doc.Get("keywords");
            Description = doc.Get("desc");
            Author = doc.Get("author");
            Location = doc.Get("loc");
            // PlainContent = doc.Get("content");
        }
示例#2
0
 public void SetProperty(Lucene.Net.Documents.Document doc)
 {
     if (doc != null)
     {
         this.SchoolId = XConvert.ToInt32(doc.Get("SchoolId"), -1);
         this.Type = (SchoolType)XConvert.ToByte(doc.Get("Type"));
         this.Name = doc.Get("Name");
         this.CnName = doc.Get("CnName");
         this.Pinyin = doc.Get("Pinyin");
         this.RegionId = XConvert.ToInt32(doc.Get("RegionId"), -1);
         this.StateId = XConvert.ToInt32(doc.Get("StateId"), -1);
         this.CityId = XConvert.ToInt32(doc.Get("CityId"), -1);
     }
 }
示例#3
0
        /// <summary>
        /// ���н�����캯��
        /// </summary>
        /// <param name="doc">������</param>
        /// <param name="offset">�ؼ����������е�λ��</param>
        internal Hit(Lucene.Net.Documents.Document doc, int offset)
        {
            base.id = doc.Get("id");
            base.lastIndex = Lucene.Net.Documents.DateField.StringToDate(doc.Get("date"));

            //�����ⲿ��ŵ��ĵ�ʵ��
            StoreReader story = new StoreReader(Directorys.StoreDirectory + Math.Ceiling(Double.Parse(base.id) / 10000D).ToString("f0") + @"\" + base.id + ".gz");
            //��ȡ�ѱ��������ͷ
            base.author = story.ReadLine();
            base.cat = story.ReadLine();
            base.tag = story.ReadLine();
            base.title = story.ReadLine();
            base.path = story.ReadLine();

            int readed = 0;

            int len = 126;//��ʾ���ݳ���

            char[] block = new char[offset + len];

            //��ȡ�������ؼ��ֺ�len���ַ�
            readed = story.ReadBlock(block, 0, block.Length);

            story.Close();

            int index = offset;

            //����ؼ��ֲ��ڽ�β����ժҪ��ʼλ�ö�λ�ڹؼ���ǰһ��������֮�󣬷���ժҪȡĩβ��len���ַ�
            if (readed == block.Length)
            {
                UnicodeCategory category;
                for (; index > 0; index--)
                {
                    category = Char.GetUnicodeCategory(Char.ToLower(block[index]));
                    if (category == UnicodeCategory.OtherPunctuation)
                    {
                        index += 1;
                        break;
                    }
                }
            }
            else
            {
                index = Math.Max(0, readed - len);
            }

            //���ժҪ���ڽ�β�����ں�����ӡ�...��
            base.body = (new String(block, index, Math.Min(len - 1, readed))) + ((readed >= index + len) ? "..." : "");
        }