【问题标题】:Search engine, asp.net mvc, Domain Driven Design搜索引擎,asp.net mvc,领域驱动设计
【发布时间】:2013-06-04 12:45:28
【问题描述】:

打算开发一个搜索引擎。

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

它应该是什么样子?

我希望这是强类型的。

有什么最佳做法吗?

对架构的建议?

【问题讨论】:

    标签: asp.net-mvc architecture domain-driven-design


    【解决方案1】:

    如果您要开发一个搜索引擎,您将不得不非常快速地考虑可扩展性。在搜索相关环境中排序是一个熟悉的问题。您应该看看 Google 的搜索实现!你如何排序应该取决于ranking algorithm。以领域为中心的排名算法设计不应与排名即服务方法有如此大的不同!

    您使用哪种语言是您的选择。如果您选择 C/C++ Message Passing Interface (MPI) 进行分布式计算。如果您使用 Java,请查看 JMSGridGain(GridGain 实现了 Googles MapReduce)。

    另一个问题是,如何存储您的数据(分布式、快速、容错)!对于 Java,请查看 Project Voldemord(这是您可以免费获得的最佳系统之一。

    有关 Google 架构的更多信息,请参阅the high scalability website 了解更多信息。

    关于 DDD 的问题,请查看 dddcommunity.org,Eric Evans 本人的主页;)他写了一本非常好的书 Domain-Driven Design。 DDD 很好,因为它保证了域的完整性和完整性。

    一个简单的模型可能是:

    page ( URL url, BigInt rank, List<String> keywords, 
           List<URL> links, List<URL> outLinks, Content ref) 
    
    
    content ( GzippedBytes[] content )
    

    如果一个新节点被添加到系统中,它应该对诸如“setLinks”之类的东西做出反应,以便它可以自己获得它的页面排名。

    客户很简单,他只进行搜索(关键字),按PageRank排序。

    这是一个 服务 example of a pagerank implementation 在 Java 中。

    【讨论】:

    • 对于搜索引擎,我并不是指网络爬虫/索引器。它应该是对指定业务对象的普通搜索机制。
    • 当前搜索方法有这个签名:Get(string searchColumn, string query, string orderExpr, int startIndex, int maxRows, bool useRanks, int authorRank, int titleRank, int otherRank)。
    • 我不知道如何确保,UI 层对数据库结构一无所知,但可以对结果页面进行排序。 :)
    【解决方案2】:

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

    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;
    

    【讨论】:

      猜你喜欢
      • 2011-10-06
      • 1970-01-01
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      • 2011-01-30
      • 2011-02-04
      • 2011-03-02
      相关资源
      最近更新 更多