Frage

Why following queries return different results? In more details

  • I want to get all active posts, order by tttAt descending.
  • Doctrine2 returns my expected result but not FOSElasticaBundle
  • Doctrine2 returns all records but FOSElasticaBundle returns only 10 first records BUT please ignore this because even first 10 records from Doctrine are different from the ones from FOSElasticaBundle.

FOSElasticaBundle query:

    /** @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);

Doctrine2 query:

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

Lösung

I have just found the reason: ES is not sync with MySQL because the data in MySQL is imported, so ES did not aware of DB changes (insert, update or delete,...).

After running app/console fos:elastica:populate, the results are the same now...

My bad! Thanks @Tomdarkness :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top