FOSElasticaBundle和教义水合 [英] FOSElasticaBundle and Doctrine Hydration

查看:239
本文介绍了FOSElasticaBundle和教义水合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在忙着检查一下我开始的一个新项目的弹性搜索。我目前正在运行Symfony2.5,最新的FOSElasticaBundle和所有这些。我正在为捆绑的性能做一些基准测试(我知道弹性本身很快),但是我遇到一个小问题,可能实际上很容易解决,只有捆绑的文档更详细。



我的实际问题是简单的如何,而不是返回一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆