mplwork
mplwork

Reputation: 1150

How to do multiple replacements with Solr DIH RegexTransformer?

I am using Solr DataImportHandler with RegexTransformer and for a certain field I'd like to replace different patterns with different values. Say, replace Smith with Miller and John with Joe. A single replacement is easy:

<field column="text" regex="Smith" replaceWith="Miller"/>

But how to do the second part, replace John with Joe?

Note this is not asking for a fancy regex but rather how to apply more than one substitution on a single field.

Upvotes: 0

Views: 889

Answers (2)

mplwork
mplwork

Reputation: 1150

Found a solution. Quite simple really:

<field column="text" regex="Smith" replaceWith="Miller"/>
<field column="text" regex="John" replaceWith="Joe"/>

Upvotes: 1

Srikanth Venugopalan
Srikanth Venugopalan

Reputation: 9049

I believe, You can use groupNames to specify ordered substitutions. Refer to the original issue

Example from Solr Documentation:

<field column="fullName" regex="Mr(\w*)\b(.*)" groupNames="firstName,lastName"/>

Upvotes: 0

Related Questions