Beispiel #1
0
        /// <summary>
        ///单线程创建索引
        /// </summary>
        /// <returns></returns>
        public int CreateIndex()
        {
            List <Bpo_JobEntity> jobList     = DataRepository.GetJobList(1, 1000);
            LuceneBuild          luceneBuild = new LuceneBuild();

            return(luceneBuild.BuildIndex(jobList, path) ? 1 : 0);
        }
        /// <summary>
        ///单线程创建索引
        /// </summary>
        /// <returns></returns>
        public int CreateIndex()
        {
            DateTime             startTime   = DateTime.Now;
            List <Bpo_JobEntity> userList    = DataRepository.GetJobList(1, rowCount);
            LuceneBuild          luceneBuild = new LuceneBuild();
            int result = luceneBuild.BuildIndex(userList, path) ? 1 : 0;

            double time = (DateTime.Now - startTime).TotalSeconds;

            logHelper.Info($"创建用户({rowCount}条)索引时间:{time}秒");
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// 删除一条数据的索引
        /// </summary>
        /// <param name="jobId"></param>
        /// <returns></returns>
        public int DeleteIndex(int jobId)
        {
            Bpo_JobEntity jobEntity = DataRepository.GetJobById(jobId);

            if (jobEntity == null)
            {
                return(0);
            }

            LuceneBuild luceneBuild = new LuceneBuild();

            luceneBuild.DeleteIndex <Bpo_JobEntity>(jobEntity, "Id", path);
            return(1);
        }
Beispiel #4
0
        /// <summary>
        /// 新增一条数据的索引
        /// </summary>
        /// <param name="jobId"></param>
        /// <returns></returns>
        public int InsertIndex(int jobId)
        {
            Bpo_JobEntity jobEntity = DataRepository.GetJobById(jobId);

            if (jobEntity == null)
            {
                return(0);
            }

            LuceneBuild luceneBuild = new LuceneBuild();

            luceneBuild.InsertIndex(jobEntity, path);
            return(1);
        }
Beispiel #5
0
        /// <summary>
        /// 更新一条数据的索引
        /// </summary>
        /// <param name="jobId"></param>
        /// <returns></returns>
        public int UpdateIndex(int jobId)
        {
            Bpo_JobEntity jobEntity = DataRepository.GetJobById(jobId);

            if (jobEntity == null)
            {
                return(0);
            }
            jobEntity.UserName = "******";

            LuceneBuild luceneBuild = new LuceneBuild();

            luceneBuild.UpdateIndex <Bpo_JobEntity>(jobEntity, "Id", path);
            return(1);
        }
        private bool mergeIndex(Task[] tasks)
        {
            try
            {
                if (cancellationTokenSource.IsCancellationRequested)
                {
                    return(false);
                }
                LuceneBuild luceneBuild = new LuceneBuild();

                luceneBuild.MergeIndex(path, childDirList.ToArray());

                return(true);
            }
            catch (Exception ex)
            {
                logHelper.Error($"合并索引出现异常", ex);
                return(false);
            }
        }