Bug #46298
closed
Epic #65815: Improve Indexed search indexer
Whitespace problem
Added by Tobi no-lastname-given over 11 years ago.
Updated about 7 years ago.
Description
There is another bug. The indexer writes to the db table index_phash in field item_description. But there are to many whitespaces in the string. So you get just a view words. In the Indexer.php around line 1309 you have to change the following:
/**
* Extracts the sample description text from the content array.
*
* @param array Content array
* @return string Description string
* @todo Define visibility
*/
public function bodyDescription($contentArr) {
// Setting description
$maxL = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->conf['index_descrLgd'], 0, 255, 200);
if ($maxL) {
// Shorten the string:
//$bodyDescription = str_replace(array(TAB, CR, LF,' '), ' ', $contentArr['body']);
$bodyDescription = preg_replace('/\s+/', ' ', $contentArr['body']);
$bodyDescription = $this->csObj->strtrunc('utf-8', $bodyDescription, $maxL);
}
return $bodyDescription;
}
Use preg_replace preg_replace('/\s+/' ... this removes all whitespaces and replaces width one whitespace
There is another bug. The indexer writes to the db table index_phash in field item_description. But there are to many whitespaces in the string. So you get just a view words. In the Indexer.php around line 1309 you have to change the following:
/**
* Extracts the sample description text from the content array.
*
* @param array Content array
* @return string Description string
* @todo Define visibility
*/
public function bodyDescription($contentArr) {
// Setting description
$maxL = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->conf['index_descrLgd'], 0, 255, 200);
if ($maxL) {
// Shorten the string:
//$bodyDescription = str_replace(array(TAB, CR, LF,' '), ' ', $contentArr['body']);
$bodyDescription = preg_replace('/\s+/', ' ', $contentArr['body']);
$bodyDescription = $this->csObj->strtrunc('utf-8', $bodyDescription, $maxL);
}
return $bodyDescription;
}
Use preg_replace preg_replace('/\s+/' ... this removes all whitespaces and replaces width one whitespace
Hi Tobi,
can you make patches and add them to gerrit please?
- Subject changed from Description Length to Whitespace problem
- Target version changed from 6.1.0-beta1 to 2222
- Project changed from 1382 to TYPO3 Core
- Category set to Indexed Search
- Target version deleted (
2222)
- Target version set to 7.5
- TYPO3 Version set to 4.5
- Is Regression set to No
- Parent task set to #65815
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/41375
- Status changed from Under Review to Resolved
- % Done changed from 10 to 100
- Status changed from Resolved to Closed
Also available in: Atom
PDF