Skip to content

Commit

Permalink
EZEE-1871: Solr cannot index string field which is too large.
Browse files Browse the repository at this point in the history
Resolves #84
  • Loading branch information
xserna authored and andrerom committed Oct 4, 2019
1 parent 7ada681 commit 48b252a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/FieldType/XmlText/SearchField.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private function extractText(DOMNode $node)
private function extractShortText(DOMDocument $document)
{
$result = null;
// try to extract first paragraph/tag
if ($section = $document->documentElement->firstChild) {
$textDom = $section->firstChild;

Expand All @@ -95,7 +96,10 @@ private function extractShortText(DOMDocument $document)
$result = $document->documentElement->textContent;
}

return trim($result);
// In case of newlines, extract first line. Also limit size to 255 which is maxsize on sql impl.
$lines = preg_split('/\r\n|\n|\r/', trim($result), -1, PREG_SPLIT_NO_EMPTY);

return empty($lines) ? '' : trim(mb_substr($lines[0], 0, 255));
}

/**
Expand Down

0 comments on commit 48b252a

Please sign in to comment.