[ 
https://issues.apache.org/jira/browse/SOLR-8607?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15122751#comment-15122751
 ] 

Steve Rowe commented on SOLR-8607:
----------------------------------

This workaround allowed me to create the {{new_txt}} field: first delete the 
matching dynamic field, then add the new field, then re-add the deleted dynamic 
field, all in one request:

{noformat}
$ curl -X POST -H "Content-type:application/json" --data-binary '{
"delete-dynamic-field":{"name":"*_txt"},
"add-field": 
{"name":"new_txt","type":"string","indexed":"true","stored":"true"},
"add-dynamic-field":{"name":"*_txt", "type":"text_general", "indexed":true, 
"stored":true}}' \
http://localhost:8983/solr/gettingstarted/schema

{"responseHeader": {"status":0, "QTime":81}}

$ curl http://localhost:8983/solr/gettingstarted/schema
[...]
"fields":[...{"name":"new_txt", "type":"string", "indexed":true,"stored":true}],
[...]
"dynamicFields":[...,{"name":"*_txt", "type":"text_general", "indexed":true, 
"stored":true},
[...]
{noformat}

> The Schema API refuses to add new fields that match existing dynamic fields
> ---------------------------------------------------------------------------
>
>                 Key: SOLR-8607
>                 URL: https://issues.apache.org/jira/browse/SOLR-8607
>             Project: Solr
>          Issue Type: Bug
>          Components: Schema and Analysis
>    Affects Versions: 5.3.1
>            Reporter: kiran
>            Priority: Minor
>
> 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*: 
> {code}
> 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":[]}}
> {code}
> *Create new field 'userId' using Schema API*
> {code}
> 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"]}]}
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to