Skip to main content

RegexLinkExtractor

Extracts links from documents using regular expression patterns.

Notesโ€‹

Extracts links from documents using regular expressions. Each pattern can include a match group to capture the URL and an optional replacement expression to construct the final URL from the match. Supports content-type restrictions and URL length limits.

Examplesโ€‹

The following example extracts page "ids" contained in square brackets and add them to a custom URL.

class: RegexLinkExtractor
patterns:
- match: \[(\d+)\]
replace: http://www.example.com/page?id=$1

Usageโ€‹

Full configuration skeleton, with every option and its default
class: RegexLinkExtractor
charset: string
contentTypeMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
fieldMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
maxUrlLength: 0
patterns:
- match: string
replace: string
restrictions:
- fieldMatcher: {}
valueMatcher: {}

Propertiesโ€‹

PropertyTypeRequiredDefault
charsetstringNo-
contentTypeMatcherTextMatcherNoTextMatcher
fieldMatcherTextMatcherNoTextMatcher
maxUrlLengthintegerNo2048
patternsExtractionPattern[]No-
restrictionsPropertyMatcher[]No-

Property Detailsโ€‹

charsetโ€‹

The character encoding to use when reading or writing the document.

contentTypeMatcherโ€‹

Restricts processing to documents whose content type matches the specified pattern. When not set, the handler applies to all content types.

fieldMatcherโ€‹

Matches document fields based on specified patterns and methods. Use this to restrict the handler to operate only on fields whose names satisfy the matcher criteria.

maxUrlLengthโ€‹

The maximum supported URL length in characters. URLs exceeding this length are ignored. Default is 2048.

patternsโ€‹

A list of extraction patterns, each consisting of a match regular expression and an optional replace expression for constructing the final URL from captured groups.

restrictionsโ€‹

Defines filter conditions that restrict which documents this committer processes. Documents not matching the restrictions are ignored by this committer.