Solr
  1. Solr
  2. SOLR-7682

Schema API - Add New Copy Field Rule doesn't allow maxChars parameter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.2
    • Fix Version/s: 5.3, 6.0
    • Component/s: Schema and Analysis
    • Labels:
      None

      Description

      As shown in the Schema API documentation
      https://cwiki.apache.org/confluence/display/solr/Schema+API#SchemaAPI-AddaNewCopyFieldRule

      when adding a new copy field rule, the maxChars argument can be also specified.

      When trying to execute the request :

      curl -X POST -H 'Content-type:application/json' --data-binary '{
        "add-copy-field":{
           "source":"name",
           "dest":[ "secondname"],
           "maxChars" : "3000"}
      }' http://localhost:8983/solr/films/schema
      

      (after creating a core

      bin/solr create -c films

      , and creating two text fields

      curl http://localhost:8983/solr/films/schema -X POST -H 'Content-type:application/json' --data-binary '{
          "add-field" : {
              "name":"name",
              "type":"text_general",
              "stored":true
          },
         "add-field" : {
              "name":"secondname",
              "type":"text_general",
              "stored":true
          }
      }'
      

      the error message shown is

        "responseHeader":{
          "status":0,
          "QTime":1},
        "errors":[{
            "add-copy-field":{
              "source":"name",
              "dest":["secondname"],
              "maxChars":"3000"},
            "errorMessages":["Only the 'source' and 'dest' params are allowed with the 'add-copy-field' operation"]}]}
      

      which occurs due to the handling in SchemaManager.java file

              if ( ! op.getValuesExcluding(SOURCE, DESTINATION).isEmpty()) {
                op.addError("Only the '" + SOURCE + "' and '" + DESTINATION
                    + "' params are allowed with the 'add-copy-field' operation");
                return false;
              }
      

        Issue Links

          Activity

          Hide
          Steve Rowe added a comment -

          Patch adding maxChars support and modifying TestBulkSchemaAPI to test for it.

          I'll commit after all solr tests and precommit pass.

          Show
          Steve Rowe added a comment - Patch adding maxChars support and modifying TestBulkSchemaAPI to test for it. I'll commit after all solr tests and precommit pass.
          Hide
          ASF subversion and git services added a comment -

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

          SOLR-7682: Schema API - Add New Copy Field Rule doesn't allow maxChars parameter

          Show
          ASF subversion and git services added a comment - Commit 1685900 from Steve Rowe in branch 'dev/trunk' [ https://svn.apache.org/r1685900 ] SOLR-7682 : Schema API - Add New Copy Field Rule doesn't allow maxChars parameter
          Hide
          ASF subversion and git services added a comment -

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

          SOLR-7682: Schema API - Add New Copy Field Rule doesn't allow maxChars parameter (merged trunk r1685900)

          Show
          ASF subversion and git services added a comment - Commit 1685903 from Steve Rowe in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1685903 ] SOLR-7682 : Schema API - Add New Copy Field Rule doesn't allow maxChars parameter (merged trunk r1685900)
          Hide
          Steve Rowe added a comment -

          Committed to trunk and branch_5x.

          Thanks Marius for reporting.

          Show
          Steve Rowe added a comment - Committed to trunk and branch_5x. Thanks Marius for reporting.
          Hide
          Marius Grama added a comment -

          Steve Rowe the copy fields can be modified also through CopyFieldsCollectionResource.
          I guess that maxChars should be also handled by this resource like in the following call :

          curl http://localhost:8983/solr/films/schema/copyfields -X POST  -H 'Content-type:application/json' --data-binary '[
              {
                "source":"name",
                "dest":"secondname",
                "maxChars" : 100}
          ]'
          

          I think the functionality of this resource should be extended as well. If so, you could merge the functionality of ManagedIndexSchema.addCopyFields methods into one method.

          Show
          Marius Grama added a comment - Steve Rowe the copy fields can be modified also through CopyFieldsCollectionResource. I guess that maxChars should be also handled by this resource like in the following call : curl http: //localhost:8983/solr/films/schema/copyfields -X POST -H 'Content-type:application/json' --data-binary '[ { "source" : "name" , "dest" : "secondname" , "maxChars" : 100} ]' I think the functionality of this resource should be extended as well. If so, you could merge the functionality of ManagedIndexSchema.addCopyFields methods into one method.
          Hide
          Steve Rowe added a comment -

          Marius, I intentionally did not update CopyFieldsCollectionResource, because it will be deprecated - see SOLR-6594. Although that deprecation has not yet happened, information about the REST non-bulk methods of modifying the schema was removed from the Solr Reference guide a few versions ago.

          Following deprecation on branch_5x, we'll remove these schema modification methods from trunk, and in that process, there will be several methods in (Managed)IndexSchema, including the older addCopyFields method, that will be removed.

          Show
          Steve Rowe added a comment - Marius, I intentionally did not update CopyFieldsCollectionResource, because it will be deprecated - see SOLR-6594 . Although that deprecation has not yet happened, information about the REST non-bulk methods of modifying the schema was removed from the Solr Reference guide a few versions ago. Following deprecation on branch_5x, we'll remove these schema modification methods from trunk, and in that process, there will be several methods in (Managed)IndexSchema, including the older addCopyFields method, that will be removed.
          Hide
          Marius Grama added a comment -

          Thanks for the heads up Steve Rowe

          Show
          Marius Grama added a comment - Thanks for the heads up Steve Rowe
          Hide
          Shalin Shekhar Mangar added a comment -

          Bulk close for 5.3.0 release

          Show
          Shalin Shekhar Mangar added a comment - Bulk close for 5.3.0 release

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development