FOSElasticaBundle 和 Doctrine Hydration [英] FOSElasticaBundle and Doctrine Hydration
问题描述
我正忙于检查我正在启动的新项目的 elasticsearch.我目前正在运行 Symfony2.5,以及最新的 FOSElasticaBundle 等等.我正在对捆绑包的性能进行一些基准测试(我知道弹性本身非常快),但我遇到了一个实际上可能很容易解决的小问题,如果捆绑包的文档更详细的话.
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.
我的实际问题只是如何,而不是返回一组 Doctrine 对象(我认为这些对象是通过数据库查询填充的),而是从 Elastica 本身返回响应的原始"数组?包括响应时间、最大分数等.FOSElasticaBundle 的文档在这些主题上非常模糊......
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?
感谢您的帮助!
推荐答案
找到了答案... 一点点睡眠似乎可以让人走很长的路.
Found the answer... Little bit of sleep can get a person a long way it seems.
如果其他人想弄清楚这一点,在经历了整个 hydrate: false
事情之后,还有什么不是(顺便说一下,这与这个问题没有任何关系).
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).
只需使用该服务:
$this->get('fos_elastica.index.app.foo')->search($query)
获取 Elastica Type 实例.
$this->get('fos_elastica.index.app.foo')->search($query)
to get the Elastica Type instance.
$this->get('fos_elastica.finder.app.foo')->find($query)
获取 Doctrine 实体的数组.
$this->get('fos_elastica.finder.app.foo')->find($query)
gets an array of Doctrine entities.
希望这对某人有所帮助.
Hope this helps someone.
这篇关于FOSElasticaBundle 和 Doctrine Hydration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!