Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-7542

Schema API: Can't remove single dynamic copy field directive

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.1
    • Fix Version/s: 5.2
    • Component/s: None
    • Labels:
      None

      Description

      In a managed schema containing just a single dynamic copy field directive - i.e. a glob source or destination - deleting the copy field directive fails. For example, the default configset (data_driven_schema_configs) has such a schema: the *->_text_ copy field directive is the only one.

      To reproduce:

      bin/solr start -c
      bin/solr create my_solr_coll
      curl "http://localhost:8983/solr/my_solr_coll/schema" -d'{"delete-copy-field":{"source":"*", "dest":"_text_"}}'
      

      The deletion fails, and an NPE is logged:

      ERROR - 2015-05-13 12:37:36.780; [my_solr_coll shard1 core_node1 my_solr_coll_shard1_replica1] org.apache.solr.common.SolrException; null:java.lang.NullPointerException
              at org.apache.solr.schema.IndexSchema.getCopyFieldProperties(IndexSchema.java:1450)
              at org.apache.solr.schema.IndexSchema.getNamedPropertyValues(IndexSchema.java:1406)
              at org.apache.solr.schema.IndexSchema.persist(IndexSchema.java:390)
              at org.apache.solr.schema.SchemaManager.doOperations(SchemaManager.java:120)
              at org.apache.solr.schema.SchemaManager.performOperations(SchemaManager.java:94)
              at org.apache.solr.handler.SchemaHandler.handleRequestBody(SchemaHandler.java:57)
              at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
              at org.apache.solr.core.SolrCore.execute(SolrCore.java:1984)
              at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:829)
              at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:446)
              at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:220)
      [...]
      

        Activity

        Hide
        anshumg Anshum Gupta added a comment -

        Bulk close for 5.2.0.

        Show
        anshumg Anshum Gupta added a comment - Bulk close for 5.2.0.
        Hide
        steve_rowe Steve Rowe added a comment -

        Committed to trunk and branch_5x.

        Show
        steve_rowe Steve Rowe added a comment - Committed to trunk and branch_5x.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1679229 from Steve Rowe in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1679229 ]

        SOLR-7542: Schema API: Can't remove single dynamic copy field directive (merged trunk r1679225)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1679229 from Steve Rowe in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1679229 ] SOLR-7542 : Schema API: Can't remove single dynamic copy field directive (merged trunk r1679225)
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1679225 from Steve Rowe in branch 'dev/trunk'
        [ https://svn.apache.org/r1679225 ]

        SOLR-7542: Schema API: Can't remove single dynamic copy field directive

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1679225 from Steve Rowe in branch 'dev/trunk' [ https://svn.apache.org/r1679225 ] SOLR-7542 : Schema API: Can't remove single dynamic copy field directive
        Hide
        steve_rowe Steve Rowe added a comment -

        Patch with test that fails before applying the fix and succeeds afterward.

        I've added null checks on all access to the dynamic copy fields array in IndexSchema.

        Committing shortly.

        Show
        steve_rowe Steve Rowe added a comment - Patch with test that fails before applying the fix and succeeds afterward. I've added null checks on all access to the dynamic copy fields array in IndexSchema. Committing shortly.
        Hide
        steve_rowe Steve Rowe added a comment -

        The issue is that the schema can't be persisted once there are no more dynamic copy fields (glob copy field directives).

        One workaround is to first add another copy field directive (e.g. *unlikely_field_suffix->_text_). The copy field directive that you want to remove (*->_text_ in our example) can then be successfully deleted.

        The fix is a null check on the internal array containing the dynamic copy fields.

        AFAICT, this is also a problem in schemas that start out with zero dynamic copy fields - in that case I think it won't be possible to make any schema modifications at all.

        Show
        steve_rowe Steve Rowe added a comment - The issue is that the schema can't be persisted once there are no more dynamic copy fields (glob copy field directives). One workaround is to first add another copy field directive (e.g. *unlikely_field_suffix -> _text_ ). The copy field directive that you want to remove ( * -> _text_ in our example) can then be successfully deleted. The fix is a null check on the internal array containing the dynamic copy fields. AFAICT, this is also a problem in schemas that start out with zero dynamic copy fields - in that case I think it won't be possible to make any schema modifications at all.

          People

          • Assignee:
            steve_rowe Steve Rowe
            Reporter:
            steve_rowe Steve Rowe
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development