9

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!

4

1 に答える 1

16

答えが見つかりました... 少しの睡眠で人は長い道のりを歩むことができるようです。

他の誰かがこれを理解しようとしている場合、すべてを調べた後、そうhydrate: falseではありません(ちなみに、これはこの質問とはまったく関係ありません)。

サービスを使用するだけです:

$this->get('fos_elastica.index.app.foo')->search($query)Elastica Type インスタンスを取得します。

$this->get('fos_elastica.finder.app.foo')->find($query)Doctrine エンティティの配列を取得します。

これが誰かに役立つことを願っています。

于 2014-06-06T07:34:58.520 に答える