コード例 #1
0
        public Dictionary <string, IEnumerable <int> > Search(IEnumerable <ModuleInfo> modules, int tenantID)
        {
            var result = new Dictionary <string, IEnumerable <int> >();

            foreach (var module in modules)
            {
                try
                {
                    var ids = new List <int>();

                    var temp = module.SqlQuery;

                    module.SqlQuery = temp.Replace(module.Name, TextIndexCfg.Chunks > 1 ? module.GetChunkByTenantId(tenantID, TextIndexCfg.Chunks, TextIndexCfg.Dimension) : module.Main);
                    ids.AddRange(DbProvider.Search(module));

                    module.SqlQuery = temp.Replace(module.Name, module.Delta);
                    ids.AddRange(DbProvider.Search(module));

                    result.Add(module.Name, ids);
                }
                catch (Exception e)
                {
                    Start();
                    log.ErrorFormat("Searchd: search failed, module :{0}, exception:{1}", module.Name, e.Message);
                }
            }

            return(result);
        }
コード例 #2
0
        public Dictionary <string, IEnumerable <int> > Search(IEnumerable <ModuleInfo> modules)
        {
            var result = new Dictionary <string, IEnumerable <int> >();

            foreach (var module in modules)
            {
                try
                {
                    var ids = DbProvider.Search(module);
                    result.Add(module.Name, ids);
                }
                catch (Exception e)
                {
                    Start();
                    log.Error("Searchd: search failed", e);
                }
            }

            return(result);
        }
コード例 #3
0
        public int[] Search(string[] modules, int tenantID)
        {
            var result = new Dictionary <string, int[]>();

            foreach (var module in modules)
            {
                try
                {
                    var ids = new List <int>();

                    var name = module.Substring(0, module.IndexOf("|"));
                    var sql  = module.Substring(module.IndexOf("|") + 1);

                    var mainname = name + "_main";
                    if (1 < TextIndexCfg.Chunks)
                    {
                        var index = tenantID / TextIndexCfg.Dimension;
                        if (index >= TextIndexCfg.Chunks)
                        {
                            index = TextIndexCfg.Chunks - 1;
                        }
                        mainname = ModuleInfo.GetChunk(name, index + 1);
                    }
                    var replacedSql = sql.Replace(name, mainname);
                    ids.AddRange(DbProvider.Search(replacedSql));

                    replacedSql = sql.Replace(name, name + "_delta");
                    ids.AddRange(DbProvider.Search(replacedSql));

                    result.Add(name, ids.ToArray());
                }
                catch (Exception e)
                {
                    Start();
                    log.ErrorFormat("Searchd: search failed, module :{0}, exception:{1}", module, e.Message);
                }
            }

            return(result.SelectMany(r => r.Value).Distinct().ToArray());
        }