问题描述
我正在忙着检查一下我开始的一个新项目的弹性搜索。我目前正在运行Symfony2.5,最新的FOSElasticaBundle和所有这些。我正在为捆绑的性能做一些基准测试(我知道弹性本身很快),但是我遇到一个小问题,可能实际上很容易解决,只有捆绑的文档更详细。我的实际问题是简单的如何,而不是返回一个Doctrine对象数组(我相信通过DB查询填充)返回一个raw数组来自Elastica本身的回应?包括响应时间,最大分数等。FOSElasticaBundle的文档在这些主题上是相当模糊的。
似乎有点反效果和缓慢的当您已经拥有弹性的所有信息时,重新查询数据库?还是有一些非常明显的东西,我在这里缺少?
感谢任何帮助!
找到答案...有点睡觉可以让一个人看起来很漫长。
如果有人试图弄清楚这一点,经过整个水合物:false
(这不以任何方式与此问题无关),只需使用服务 fos_elastica.index.search。{type_name}
而不是 fos_elastica.finder.search。{type_name}
以获取Elastica Type实例,而不是Doctrine实体的数组。
希望这有助于某人。
I'm busy checking out elasticsearch for a new project that I'm starting on. I'm currently running Symfony2.5, with the latest FOSElasticaBundle and all that. I'm doing some benchmarks into performance of the bundle (I know elastic in itself is pretty darn fast), but I've come across a small problem that may actually be easy to solve, if only the bundle's documentation were more verbose.
My actual question is simply how to, instead of returning an array of Doctrine objects (which I believe are populated via a DB query), to return a "raw" array of the response from Elastica itself? Including the response time, max score, etc. The docs for the FOSElasticaBundle are pretty vague on these topics...
It seems a bit counter-productive and slow to have to re-query the database when you already have all the information you're looking for from elastic? Or is there something very obvious that I'm missing here?
Thanks for any help!
Found the answer... Little bit of sleep can get a person a long way it seems.
If anybody else is trying to figure this out, after going through the whole hydrate: false
thing and what not (which is not related to this question in any way, by the way), simply use the service fos_elastica.index.search.{type_name}
instead of fos_elastica.finder.search.{type_name}
to get the Elastica Type instance, instead of an array of Doctrine entities.
Hope this helps someone.
这篇关于FOSElasticaBundle和教义水合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!