Skip to content

Commit

Permalink
Don't sort if fulltext field for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwindell authored May 26, 2020
1 parent ca58162 commit 19de92b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Edge/Doctrine/Search/DoctrineSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ public function getResults($offset, $itemCountPerPage)
$qb->andWhere($expressions);
}

$hasFulltext = false;
$keywordFields = $this->getOptions()->getKeywordFields();
if (!empty($keywordFields) && null !== $filter->getKeywords()) {
$hasFulltext = false;
if (!empty($keywordFields) && null !== $filter->getKeywords()) {
$orX = $qb->expr()->orX();

foreach ($keywordFields as $field) {
Expand All @@ -159,7 +159,7 @@ public function getResults($offset, $itemCountPerPage)
}
}

if (null !== $filter->getSortField()) {
if (null !== $filter->getSortField() && !$hasFulltext) {
$mappedSortField = $this->getMappedField($filter->getSortField());
$this->addJoin($mappedSortField['field']);
$qb->orderBy($mappedSortField['field'], $filter->getSortOrder());
Expand Down

0 comments on commit 19de92b

Please sign in to comment.