- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我首先使用以下包含语句对我的 solr 索引的 2 个版本进行了基准测试:
searchable(:auto_index => false, :auto_remove => true,
:include => { :account => true,
:user_practice_contact => [:city],
:user_professional_detail => [:specialty, :subspecialties]}) do
第二个:
searchable(:auto_index => false, :auto_remove => true) do
我原以为包含的版本会出现减速,但结果如下:
版本包含:
Benchmark.measure { User.limit(50).each do |u|; u.index; end; Sunspot.commit; }
=> #<Benchmark::Tms:0x1130b34e8 @real=6.8079788684845, @utime=5.05, @cstime=0.0, @cutime=0.0, @total=5.2, @label="", @stime=0.149999999999999>
没有包括:
Benchmark.measure { User.limit(50).each do |u|; u.index; end; Sunspot.commit; }
=> #<Benchmark::Tms:0x112ef0fe8 @real=6.82465195655823, @utime=4.92, @cstime=0.0, @cutime=0.0, @total=5.07, @label="", @stime=0.15>
有人知道包含是否应该起作用吗?如果是这样,我做错了吗?我查看了文档:http://outoftime.github.com/sunspot/rails/docs/并没有提到这一点。
最佳答案
根据 the API , :include
将:
allow ActiveRecord to load required associations when indexing.
您的基准测试无法正常工作,因为您在普通的 Ruby 迭代器中索引单个记录。当您为单个记录编制索引 50 次时,Sunspot 根本无法使用预先加载。相反,你应该这样做:
Sunspot.index( User.limit(50) );
Sunspot.commit
哦,你能测试下面是否比上面更快吗?我真的很想知道。
Sunspot.index( User.includes(:account).limit(50) );
Sunspot.commit
还有一个bug目前,STI 模型将忽略 :include
。
关于ruby - 是否为 :include inside a sunspot/solr searchable method do anything?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7287943/
我支持 Rails 项目,其中包含 Rails 应用程序和 Solr 的附加实例。 我的环境:rails 3.2.1、ruby 2.1.2、sunspot 2.1.0、Solr 4.1.6。 问题:
在 Solr 中添加和提交之间的根本区别是什么?我们已经阅读了几个文档,但现在仍然非常清楚它到底做了什么,以及何时使用 Add 和何时使用 Commit? 据我了解,Add 将数据添加到 solr 数
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 5年前关闭。 Improve t
我们可以在 solr suggester 响应中添加上下文而不是上下文过滤吗? 我有 5 个不同的类别。每个类别都有不同的名称。我的建议者在名字上工作。我可以得到如下输出吗? { "term" :
在 solrconfig.xml 中,filterCache(或 queryResultCache 等)的 'autowarmCount' 表示当新的搜索者到来时将复制多少缓存实体。但是,如果我在 s
我们计划部署 Solr 来搜索从通用 CMS 平台发布的多个站点。 每种语言都有单独的网站,其他语言的内容主要是从英语翻译过来的。 搜索要求包括 – 关键字突出显示、建议(“你是什么意思?”)、停用词
我们有一个系统,使用户能够创建应用程序并在其应用程序上存储数据。我们希望将每个应用程序的索引分开。我们为每个应用程序创建一个核心,并在用户进行查询时搜索给定的应用程序。由于应用程序之间没有任何关系,因
我写了一个小型搜索引擎作为我的每周项目。它基于查询向量和文档向量之间的余弦相似度。向量是使用 tf-idf 标记的疮计算的。 我开始了解 Apache Solr,它是一个全文搜索引擎。我的问题是 so
为了索引我的网站,我有一个 Ruby 脚本,它反过来生成一个 shell 脚本,将我的文档根目录中的每个文件上传到 Solr。 shell 脚本有很多行,如下所示: curl -s \ "htt
是否可以分享Solr fieldType s 定义于 schema.xml多核之间? 我在 Solr 中有许多核心,发现自己正在重新定义 fieldType s 仅基于内置过滤器和分词器。例如
我想通过命令停止 solr 所以如果找到这篇文章 http://rc98.net/solrinit echo "Stopping Solr" cd $SOLR_DIR
我想用守护进程运行 solr。我在另一篇文章中看到有一个可以运行的 init.d 脚本,但它在我的 ubuntu 环境中似乎有问题。每当我尝试使用/etc/init.d/solr start 运行脚本
我有一个 solr 搜索返回上下文突出显示结果,显示网址和电子邮件,句点后带有空格 - 例如“www.google.com”或“email@google.com”无论如何要关闭它,以便它们正常显示?谢
我遇到了一个问题,其中一个列是多值的。例如:值可以是 (11,22) (11,33) (11,55) , (22,44) , (22,99) 我想执行一个分组操作,它将产生: 11 : 计数 3 22
这个问题在这里已经有了答案: How to select distinct field values using Solr? (6 个回答) 6年前关闭。 我有如下 solr 索引数据 7920
背景 使用 Solr 4.0.0。我已经索引了一组示例文档的文本并启用了术语向量,因此我可以使用快速向量突出显示 为了突出显示,我正在使用带有句子边界的 Break Iterator Boundar
题 我在哪里可以找到一个完整的示例,该示例展示了从索引文档到检索搜索结果的分层分面搜索是如何工作的? 我的研究到目前为止 Stackoverflow 有一些帖子,但它们都只针对分层分面搜索的某些方面;
我正在尝试开始使用 Apache Solr,但有些事情我不清楚。通读tutorial ,我已经设置了一个正在运行的 Solr 实例。我感到困惑的是 Solr 的所有配置(架构等)都是 XML 格式的。
我将以下文档存储在 Solr 中: doc { id: string; // this is a unique string that looks like an md5 result
我有一个关于在 solr 中创建嵌套字段的可能性的问题。 谷歌搜索告诉我一些关于组的信息,但我认为它只是为了结果? 我想要的是这样的结构: 类别1 项目 1 (9) 项目 2 (8) 类别2 项目 3
我是一名优秀的程序员,十分优秀!