Solr
  1. Solr
  2. SOLR-6383

regexTransformer returns no results if there is no match

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.10, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      When used in data-import config file to replace spaces in title with _

      <field column="title_underscore" regex="\s+" replaceWith="_"
      sourceColName="title" />

      regexTransformer returns empty results for titles without spaces, i.e. when there is no match for the regex. According to the description it is equivalent to replaceAll which returns string when there is no match.

      1. regexTransformer.patch
        0.8 kB
        Alexander Kingson
      2. SOLR-6383.patch
        3 kB
        Shalin Shekhar Mangar

        Activity

        Hide
        Alexander Kingson added a comment - - edited

        This is a quick fix. It is tested only for the above mentioned case.

        Show
        Alexander Kingson added a comment - - edited This is a quick fix. It is tested only for the above mentioned case.
        Hide
        Shalin Shekhar Mangar added a comment -

        Thanks Alexander. We shouldn't use replaceAll directly because that will cause the Pattern to be recompiled on each replace which is very wasteful. So I've reverted the code to use the original getPattern method but we return the original value if the regex doesn't match. I've added a test as well.

        Show
        Shalin Shekhar Mangar added a comment - Thanks Alexander. We shouldn't use replaceAll directly because that will cause the Pattern to be recompiled on each replace which is very wasteful. So I've reverted the code to use the original getPattern method but we return the original value if the regex doesn't match. I've added a test as well.
        Hide
        ASF subversion and git services added a comment -

        Commit 1618488 from shalin@apache.org in branch 'dev/trunk'
        [ https://svn.apache.org/r1618488 ]

        SOLR-6383: RegexTransformer returns no results after replaceAll if regex does not match a value

        Show
        ASF subversion and git services added a comment - Commit 1618488 from shalin@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1618488 ] SOLR-6383 : RegexTransformer returns no results after replaceAll if regex does not match a value
        Hide
        ASF subversion and git services added a comment -

        Commit 1618489 from shalin@apache.org in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1618489 ]

        SOLR-6383: RegexTransformer returns no results after replaceAll if regex does not match a value

        Show
        ASF subversion and git services added a comment - Commit 1618489 from shalin@apache.org in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1618489 ] SOLR-6383 : RegexTransformer returns no results after replaceAll if regex does not match a value
        Hide
        Shalin Shekhar Mangar added a comment -

        Thanks Alexander!

        Show
        Shalin Shekhar Mangar added a comment - Thanks Alexander!
        Hide
        Okke Klein added a comment -

        For my use case I do not want the original value being used if there is no match. Maybe support both behaviors with an argument "useOriginal="(true/false)"?

        Show
        Okke Klein added a comment - For my use case I do not want the original value being used if there is no match. Maybe support both behaviors with an argument "useOriginal="(true/false)"?
        Hide
        Jens added a comment -

        I would also prefer the previous behaviour as it was added in SOLR-1080

        Show
        Jens added a comment - I would also prefer the previous behaviour as it was added in SOLR-1080

          People

          • Assignee:
            Shalin Shekhar Mangar
            Reporter:
            Alexander Kingson
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development