Esempio n. 1
0
        public void UpdateTagInOwner(IEnumerable <TagInOwner> tagInOwners)
        {
            IEnumerable <Document> docs          = TagIndexDocument.Convert(tagInOwners);
            List <string>          tagInOwnerIds = new List <string>();

            foreach (TagInOwner tagInOwner in tagInOwners)
            {
                tagInOwnerIds.Add(tagInOwner.Id.ToString());
            }
            searchEngine.Update(docs, tagInOwnerIds, TagIndexDocument.TagInOwnerId);
        }
Esempio n. 2
0
        public void InsertTagInOwner(IEnumerable <TagInOwner> tagInOwners)
        {
            List <Document> docs = new List <Document>();

            foreach (var tagInOwner in tagInOwners)
            {
                Document doc = TagIndexDocument.Convert(tagInOwner);
                if (doc != null)
                {
                    docs.Add(doc);
                }
            }
            searchEngine.Insert(docs);
        }
Esempio n. 3
0
        public void UpdateTagInOwner(TagInOwner tagInOwner)
        {
            Document doc = TagIndexDocument.Convert(tagInOwner);

            searchEngine.Update(doc, tagInOwner.Id.ToString(), TagIndexDocument.TagInOwnerId);
        }
Esempio n. 4
0
        /// <summary>
        /// 更新索引
        /// </summary>
        public void UpdateTag(Tag tag)
        {
            Document doc = TagIndexDocument.Convert(tag);

            searchEngine.Update(doc, tag.TagId.ToString(), TagIndexDocument.TagId);
        }
Esempio n. 5
0
        /// <summary>
        /// 重建索引
        /// </summary>
        public void RebuildIndex()
        {
            //pageSize参数决定了每次批量取多少条数据进行索引。要注意的是,如果是分布式搜索,客户端会将这部分数据通过WCF传递给服务器端,而WCF默认的最大传输数据量是65535B,pageSize较大时这个设置显然是不够用的,WCF会报400错误;系统现在将最大传输量放宽了,但仍要注意一次不要传输过多,如遇异常,可适当调小pageSize的值
            bool     hasData         = true;
            int      pageSizeTags    = 1000;
            int      pageIndexTags   = 1;
            long     totalRecordTags = 0;
            bool     isBeginningTags = true;
            bool     isEnddingTags   = false;
            TagQuery tagQuery        = new TagQuery();

            do
            {
                PagingDataSet <Tag> tags = tagService.GetTags(tagQuery, pageIndexTags, pageSizeTags);
                totalRecordTags = tags.TotalRecords;
                if (totalRecordTags > 0)
                {
                    hasData = true;
                }
                isEnddingTags = (pageSizeTags * pageIndexTags < totalRecordTags) ? false : true;

                //重建索引
                List <Tag> tagList = tags.ToList <Tag>();

                IEnumerable <Document> docs = TagIndexDocument.Convert(tagList);

                searchEngine.RebuildIndex(docs, isBeginningTags, false);

                isBeginningTags = false;
                pageIndexTags++;
            }while (!isEnddingTags);

            int  pageSizeTagInOwner     = 1000;
            int  pageIndexTagInOwner    = 1;
            long totalRecordsTagInOwner = 0;
            bool isEnddingTagInOwner    = false;

            do
            {
                //分页获取帖子列表
                PagingDataSet <TagInOwner> tagInOwners = tagService.GetOwnerTags(pageIndexTagInOwner, pageSizeTagInOwner);
                totalRecordsTagInOwner = tagInOwners.TotalRecords;
                if (totalRecordsTagInOwner > 0)
                {
                    hasData = true;
                }
                isEnddingTagInOwner = (pageSizeTagInOwner * pageIndexTagInOwner < totalRecordsTagInOwner) ? false : true;

                //重建索引
                List <TagInOwner> tagInOwnerList = tagInOwners.ToList <TagInOwner>();

                IEnumerable <Document> docs = TagIndexDocument.Convert(tagInOwnerList);

                searchEngine.RebuildIndex(docs, false, false);

                pageIndexTagInOwner++;
            }while (!isEnddingTagInOwner);

            if (hasData)
            {
                searchEngine.RebuildIndex(null, false, true);
            }
        }