Solr
  1. Solr
  2. SOLR-21

Dynamic copying of fields (allow wildcard sources in copyField)

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.0
    • Component/s: update
    • Labels:
      None
    • Environment:

      all

      Description

      It would be really nice if it were possible to use wildcards to do things like:

      <copyField source="*_t" dest="text"/>

      The above example copies all fields ending in "_t" to the "text" field.

      I've put together a patch to do this. If there are mutlitple matches, all copies are done. If there is a match in a dynamicField, then the dynamic field is also generated, subject to the existing rules that short expressions go first. I tried to stick to the spirit of the code as I saw it, and made what I thought were a minimal reasonable set of changes. The patch includes some additional tests in ConvertedLegacyTest.java to test the new functionality. That may not be the best place for new tests, but it beats no tests.

      I'd really like to get this, or some improved variant of it into the codebase, as it's quite important to my application. Please review and comment/criticize as you see fit.

      1. dynamicCopy.patch
        12 kB
        Darren Erik Vengroff

        Activity

        Hide
        Darren Erik Vengroff added a comment -

        Here is the patch.

        Show
        Darren Erik Vengroff added a comment - Here is the patch.
        Show
        Darren Erik Vengroff added a comment - Note that this has previously been discussed elsewhere: http://wiki.apache.org/solr/FAQ#head-6b1d9dc2c14adecfe6fc5ce86448f15fc84baab9 http://www.nabble.com/Copy-Field-and-Dynamic-Fields-t1228725.html#a3252483 http://www.mail-archive.com/solr-user@lucene.apache.org/msg00019.html
        Hide
        Yonik Seeley added a comment -

        I just committed this. Thanks Darren!

        I did make a tweak or two...

        • changed hasExplicitField to getFieldOrNull (a getField that returns null instead of throwing an exception) since it seems like a more general method that can avoid a hash lookup.
        • throw an exception if a field being added doesn't match anything... that was the previous behavior.

        do those make sense?

        Show
        Yonik Seeley added a comment - I just committed this. Thanks Darren! I did make a tweak or two... changed hasExplicitField to getFieldOrNull (a getField that returns null instead of throwing an exception) since it seems like a more general method that can avoid a hash lookup. throw an exception if a field being added doesn't match anything... that was the previous behavior. do those make sense?
        Hide
        Hoss Man added a comment -

        This bug was modified as part of a bulk update using the criteria...

        • Marked ("Resolved" or "Closed") and "Fixed"
        • Had no "Fix Version" versions
        • Was listed in the CHANGES.txt for 1.1

        The Fix Version for all 38 issues found was set to 1.1, email notification
        was suppressed to prevent excessive email.

        For a list of all the issues modified, search jira comments for this
        (hopefully) unique string: 20080415hossman3

        Show
        Hoss Man added a comment - This bug was modified as part of a bulk update using the criteria... Marked ("Resolved" or "Closed") and "Fixed" Had no "Fix Version" versions Was listed in the CHANGES.txt for 1.1 The Fix Version for all 38 issues found was set to 1.1, email notification was suppressed to prevent excessive email. For a list of all the issues modified, search jira comments for this (hopefully) unique string: 20080415hossman3

          People

          • Assignee:
            Yonik Seeley
            Reporter:
            Darren Erik Vengroff
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development