Skip to content

Commit e90f5f1

Browse files
fix search in document filtering and highlighting
1 parent fc39af5 commit e90f5f1

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

Classes/Common/Solr/SolrSearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ public function submit($start, $rows, $processResults = true)
537537
$searchResult['highlight'] = $doc['highlight'];
538538
$searchResult['highlight_word'] = preg_replace('/^;|;$/', '', // remove ; at beginning or end
539539
preg_replace('/;+/', ';', // replace any multiple of ; with a single ;
540-
preg_replace('/[{~\d*}{\s+}{^=*\d+.*\d*}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $this->searchParams['query']))); // replace search operators and special characters with ;
540+
preg_replace('/[{~\d*}{\s+}{^=*\d+.*\d*}{\sAND\s}{\sOR\s}{\sNOT\s}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $this->searchParams['query']))); // replace search operators and special characters with ;
541541
}
542542
$documents[$doc['uid']]['searchResults'][] = $searchResult;
543543
}

Classes/Domain/Repository/DocumentRepository.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,10 @@ public function getPreviousDocumentUid($uid)
683683
return $prevDocument['uid'];
684684
}
685685

686-
return $this->getLastChild($this->getPreviousDocumentUid($parentId));
686+
$previousDocumentId = $this->getPreviousDocumentUid($parentId);
687+
if ($previousDocumentId) {
688+
return $this->getLastChild($previousDocumentId);
689+
}
687690
}
688691
}
689692

@@ -727,7 +730,10 @@ public function getNextDocumentUid($uid)
727730
return $nextDocument['uid'];
728731
}
729732

730-
return $this->getFirstChild($this->getNextDocumentUid($parentId));
733+
$nextDocumentId = $this->getNextDocumentUid($parentId);
734+
if ($nextDocumentId) {
735+
return $this->getFirstChild($nextDocumentId);
736+
}
731737
}
732738
}
733739

Classes/Middleware/SearchInDocument.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
104104
[
105105
'tx_dlf[id]' => !empty($resultDocument->getUid()) ? $resultDocument->getUid() : $parameters['uid'],
106106
'tx_dlf[page]' => $resultDocument->getPage(),
107-
'tx_dlf[highlight_word]' => $parameters['q']
107+
'tx_dlf[highlight_word]' => preg_replace('/^;|;$/', '', // remove ; at beginning or end
108+
preg_replace('/;+/', ';', // replace any multiple of ; with a single ;
109+
preg_replace('/[{~\d*}{\s+}{^=*\d+.*\d*}{\sAND\s}{\sOR\s}{\sNOT\s}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $parameters['q']))) // replace search operators and special characters with ;
108110
]
109111
);
110112

0 commit comments

Comments
 (0)