0

为什么以下查询返回不同的结果?更多细节

  • 我想获得所有活跃的帖子,按 tttAt 降序排列。
  • Doctrine2 返回我的预期结果,但不返回 FOSElasticaBundle
  • Doctrine2 返回所有记录,但 FOSElasticaBundle 仅返回 10 个第一条记录,但请忽略这一点,因为即使来自 Doctrine 的前 10 条记录也与来自 FOSElasticaBundle 的记录不同。

FOSElasticaBundle 查询:

    /** @var TransformedFinder $finder */
    $finder = $this->container->get('fos_elastica.finder.index_name.post');
    $query = new Query();
    $filter = new Term(array('status' => PostModel::STATUS_ACTIVE));
    $query->setFilter($filter);
    $query->addSort(array('tttAt' => array('order' => 'desc')));
    $posts = $finder->find($query);

教义2查询:

    $posts = $this
        ->getDoctrine()
        ->getRepository('ItlizedFairdomBundle:Post')
        ->findBy(array('status' => PostModel::STATUS_ACTIVE), array('tttAt' => 'DESC'));
4

1 回答 1

0

刚刚找到原因:ES没有和MySQL同步,因为MySQL中的数据是导入的,所以ES不知道DB的变化(插入、更新或删除,...)。

运行后app/console fos:elastica:populate,现在的结果是一样的......

我的错!谢谢@Tomdarkness :)

于 2014-04-06T07:31:57.720 回答