this patch must help

On Mon, Feb 2, 2009 at 10:49 PM, Shalin Shekhar Mangar
<shalinman...@gmail.com> wrote:
> On Mon, Feb 2, 2009 at 10:34 PM, Fergus McMenemie <fer...@twig.me.uk> wrote:
>
>>
>> Is there some simple escape or other syntax to be used or is
>> this an enhancement?
>>
>
> I guess the problem is that we are creating the regex Pattern without first
> resolving the variable. So we need to call VariableResolver.resolve on the
> 'regex' attribute's value before creating the Pattern object.
>
> Please raise an issue for this change. Nice use-case though. I guess we
> never thought someone would need to use a variable in the regex attribute :)
>
> --
> Regards,
> Shalin Shekhar Mangar.
>



-- 
--Noble Paul
Index: contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/RegexTransformer.java
===================================================================
--- contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/RegexTransformer.java	(revision 740022)
+++ contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/RegexTransformer.java	(working copy)
@@ -45,12 +45,16 @@
   @SuppressWarnings("unchecked")
   public Map<String, Object> transformRow(Map<String, Object> row,
                                           Context context) {
+    VariableResolver vr = context.getVariableResolver();
     List<Map<String, String>> fields = context.getAllEntityFields();
     for (Map<String, String> field : fields) {
       String col = field.get(DataImporter.COLUMN);
       String reStr = field.get(REGEX);
+      reStr = vr.replaceTokens(reStr);
       String splitBy = field.get(SPLIT_BY);
+      splitBy =  vr.replaceTokens(splitBy);
       String replaceWith = field.get(REPLACE_WITH);
+      replaceWith = vr.replaceTokens(replaceWith);
       if (reStr != null || splitBy != null) {
         String srcColName = field.get(SRC_COL_NAME);
         if (srcColName == null) {

Reply via email to