首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >搜索引擎、asp.net mvc、领域驱动设计

搜索引擎、asp.net mvc、领域驱动设计
EN

Stack Overflow用户
提问于 2009-03-27 08:22:46
回答 2查看 1.2K关注 0票数 1

要开发一个搜索引擎。

我想知道我的DDD应该是什么样子。应该实现对记录进行排序,但我不希望我的视图知道我的数据库结构(按哪些列进行排序)。据我所知,排序信息应该来自基础架构层,来自存储库实现,所以必须有一个灵活的域。

它应该是什么样子的?

我希望它是强类型的。

有什么最佳实践吗?

对架构的建议?

EN

Stack Overflow用户

发布于 2013-06-04 12:45:29

这是一个自定义搜索引擎的基础知识,它解析MVC视图目录,读取文件,并将提供的文本与正则表达式进行匹配。我的网站返回搜索结果的html链接。这段代码将导致创建一个列表。

代码语言:javascript
复制
List<string> results = new List<string>();
DirectoryInfo di = new DirectoryInfo  (System.Configuration.ConfigurationManager.AppSettings["PathToSearchableViews"]);
//get all view directories except the shared
foreach (DirectoryInfo d in di.GetDirectories().Where(d=>d.Name != "Shared"))
{
    //get all the .cshtml files
    foreach (FileInfo fi in d.GetFiles().Where(e=>e.Extension  == ".cshtml"))
    {
    //check if cshtml file and exclude partial pages
    if (fi.Name.Substring(0,1) != "_")
    {
        MatchCollection matches;
        bool foundMatch = false;
        int matchCount = 0;
        using (StreamReader sr = new StreamReader(fi.FullName))
        {
            string file = sr.ReadToEnd();
            foreach (string word in terms)
            {
                Regex exp = new Regex("(?i)" + word.Trim() + "(?-i)");
                matches = exp.Matches(file);
                if (matches.Count > 0)
                {
                    foundMatch = true;
                    matchCount = matches.Count;
                }
            }
         //check match count and create links
         //
         //
         }
      }
      }
  }
  return results;
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/688908

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档