FOSElasticaBundle和教义水合 [英] FOSElasticaBundle and Doctrine Hydration
问题描述
我的实际问题是简单的如何,而不是返回一个Doctrine对象数组(我相信通过DB查询填充)返回一个raw数组来自Elastica本身的回应?包括响应时间,最大分数等。FOSElasticaBundle的文档在这些主题上是相当模糊的。
似乎有点反效果和缓慢的当您已经拥有弹性的所有信息时,重新查询数据库?还是有一些非常明显的东西,我在这里缺少?
感谢任何帮助!
找到答案...有点睡觉可以让一个人看起来很漫长。
如果有人试图弄清楚这一点,经过整个水合物:false
(这不是以任何方式与此问题无关)。
只需使用该服务:
$ this-> get('fos_elastica.index.app.foo') - > search($ query)
以获取Elastica Type实例。 >
$ this-> get('fos_elastica.finder.app.foo') - > find($ query)
获得一系列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:
$this->get('fos_elastica.index.app.foo')->search($query)
to get the Elastica Type instance.
$this->get('fos_elastica.finder.app.foo')->find($query)
gets an array of Doctrine entities.
Hope this helps someone.
这篇关于FOSElasticaBundle和教义水合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!