Skip to content

Commit

Permalink
optimize source fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-sainthillier committed Mar 16, 2024
1 parent e0a006b commit 4a90ff2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/SearchRepository/CityElasticaRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function findWithSearch(?string $q): PagerfantaInterface
;

$finalQuery = Query::create($query);
$finalQuery->setSource([]); // Grab only id as we don't need other fields
$finalQuery->setSource(['id']); // Grab only id as we don't need other fields
$finalQuery->addSort(['_score' => 'DESC']);
$finalQuery->addSort(['population' => 'DESC']);

Expand Down
7 changes: 5 additions & 2 deletions src/SearchRepository/UserElasticaRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace App\SearchRepository;

use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\MultiMatch;
use FOS\ElasticaBundle\Repository;
Expand All @@ -30,7 +31,9 @@ public function findWithSearch(?string $q): PagerfantaInterface

$query->addFilter($match);

// Final Query
return $this->findPaginated($query);
$finalQuery = Query::create($query);
$finalQuery->setSource(['id']); // Grab only id as we don't need other fields

return $this->findPaginated($finalQuery);
}
}

0 comments on commit 4a90ff2

Please sign in to comment.