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

The Schema API refuses to add new fields that match existing dynamic fields

    Details

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

      Description

      If the all catch dynamic field '*' is present in a managed schema collection, then any field creation requests through Schema API return the confusing/weird error "Field ${FIELD_NAME} already exists".

      Schema of a test collection:

      curl -X GET http://localhost:8983/solr/testSQLQueries-eventsim/schema
      {
        "responseHeader":{
          "status":0,
          "QTime":0},
        "schema":{
          "name":"example",
          "version":1.5,
          "uniqueKey":"id",
          "fieldTypes":[{
              "name":"boolean",
              "class":"solr.BoolField",
              "sortMissingLast":true},
            {
              "name":"double",
              "class":"solr.TrieDoubleField",
              "positionIncrementGap":"0",
              "precisionStep":"0"},
            {
              "name":"float",
              "class":"solr.TrieFloatField",
              "positionIncrementGap":"0",
              "precisionStep":"0"},
            {
              "name":"int",
              "class":"solr.TrieIntField",
              "positionIncrementGap":"0",
              "precisionStep":"0"},
            {
              "name":"long",
              "class":"solr.TrieLongField",
              "precisionStep":"6"},
            {
              "name":"string",
              "class":"solr.StrField",
              "sortMissingLast":true},
            {
              "name":"tdate",
              "class":"solr.TrieDateField",
              "positionIncrementGap":"0",
              "precisionStep":"6"}],
          "fields":[{
              "name":"_root_",
              "type":"string",
              "indexed":true,
              "stored":false},
            {
              "name":"_version_",
              "type":"long",
              "indexed":true,
              "stored":true},
            {
              "name":"id",
              "type":"string",
              "indexed":true,
              "required":true,
              "stored":true}],
          "dynamicFields":[{
              "name":"*_tdt",
              "type":"tdate",
              "indexed":true,
              "stored":true},
            {
              "name":"*_txt",
              "type":"string",
              "multiValued":true,
              "indexed":true,
              "stored":true},
            {
              "name":"*_ss",
              "type":"string",
              "multiValued":true,
              "indexed":true,
              "stored":true},
            {
              "name":"*_ii",
              "type":"int",
              "multiValued":true,
              "indexed":true,
              "stored":true},
            {
              "name":"*_ls",
              "type":"long",
              "multiValued":true,
              "indexed":true,
              "stored":true},
            {
              "name":"*_i",
              "type":"int",
              "indexed":true,
              "stored":true},
            {
              "name":"*_s",
              "type":"string",
              "indexed":true,
              "stored":true},
            {
              "name":"*_l",
              "type":"long",
              "indexed":true,
              "stored":true},
            {
              "name":"*_b",
              "type":"boolean",
              "indexed":true,
              "stored":true},
            {
              "name":"*_f",
              "type":"float",
              "indexed":true,
              "stored":true},
            {
              "name":"*_d",
              "type":"double",
              "indexed":true,
              "stored":true},
            {
              "name":"*",
              "type":"string",
              "indexed":true,
              "stored":true}],
          "copyFields":[]}}
      

      Create new field 'userId' using Schema API

      curl -X POST -H "Content-type:application/json" --data-binary '{"add-field": {"name":"userId","type":"string","indexed":"true","stored":"true"}}' http://localhost:8983/solr/testSQLQueries-eventsim/schema
      {
        "responseHeader":{
          "status":0,
          "QTime":6},
        "errors":[{
            "add-field":{
              "name":"userId",
              "type":"string",
              "indexed":"true",
              "stored":"true"},
            "errorMessages":["Field 'userId' already exists.\n"]}]}
      

      The field 'userId' does not exist in the schema but it is also not possible to add this field because of the dynamic field '*'.

      While one should never define dynamic field '*' in a managed schema, the Schema API should atleast return some useful error message.

        Attachments

        1. SOLR-8607.patch
          5 kB
          Steve Rowe
        2. SOLR-8607.patch
          5 kB
          Steve Rowe

          Issue Links

            Activity

              People

              • Assignee:
                steve_rowe Steve Rowe
                Reporter:
                kiranch kiran
              • Votes:
                1 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: