Commit d118f60d authored by Mat's avatar Mat

similaritySearch works, without duplicate personSearch results

parent 387d3b53
Pipeline #87258 failed with stages
in 1 minute and 2 seconds
......@@ -168,17 +168,18 @@ class SimilarityPersonSearch extends AbstractSearch
{
$qb = $this->createQuery($terms, 'search');
if ($options['simplify'] ?? false) {
$qb->select(
'p.id',
'sp.id',
$qb->expr()->concat(
'p.firstName',
'sp.firstName',
$qb->expr()->literal(' '),
'p.lastName'
'sp.lastName'
).'AS text'
);
} else {
$qb->select('p');
$qb->select('sp');
}
$qb
......@@ -188,8 +189,8 @@ class SimilarityPersonSearch extends AbstractSearch
//order by firstname, lastname
$qb
->orderBy('p.firstName')
->addOrderBy('p.lastName');
->orderBy('sp.firstName')
->addOrderBy('sp.lastName');
if ($options['simplify'] ?? false) {
return $qb->getQuery()->getResult(Query::HYDRATE_ARRAY);
......@@ -204,7 +205,7 @@ class SimilarityPersonSearch extends AbstractSearch
$qb = $this->createQuery($terms);
$qb->select('COUNT(p.id)');
$qb->select('COUNT(sp.id)');
return $qb->getQuery()->getSingleScalarResult();
}
......@@ -227,8 +228,7 @@ class SimilarityPersonSearch extends AbstractSearch
$qb = $this->em->createQueryBuilder();
$qb
->select('sp')
$qb ->select('sp')
->from('ChillPersonBundle:Person', 'sp');
if ($terms['_default'] !== '') {
......@@ -239,24 +239,15 @@ class SimilarityPersonSearch extends AbstractSearch
->setParameter('default_'.$key, '%'.$gram.'%');
}
///
/// Testé avec http://localhost:8001/fr/search?q=matthieu
/// personSearch: 1 result
/// similaritySearch: 6 results - 1 = 5 results
///
$subquery = $this->personSearch->createQuery($terms)
->addSelect('p.id');
$qb->andWhere($qb->expr()
->notIn(
'sp.id',
$subquery->getDQL()
$this->personSearch
->createQuery($terms)
->addSelect('p.id')
->getDQL()
)
);
dump($subquery->getDQL());
dump($subquery->getQuery()->getResult());
///
}
//restraint center for security
......@@ -269,15 +260,7 @@ class SimilarityPersonSearch extends AbstractSearch
$this->_cacheQuery[$cacheKey] = $qb;
dump($qb->getDQL());
dump($qb->getQuery()->getResult()); //////////// <---- le résultat attendu !!
return clone $qb;
///
/// [Semantical Error] line 0, col 13 near 'p.id) FROM ChillPersonBundle:Person':
/// Error: 'p' is used outside the scope of its declaration.
///
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment