Steve Rowe created SOLR-7749:
--------------------------------

             Summary: Schema API: commands (e.g. add-field-type) should fail if 
unknown params are supplied
                 Key: SOLR-7749
                 URL: https://issues.apache.org/jira/browse/SOLR-7749
             Project: Solr
          Issue Type: Bug
            Reporter: Steve Rowe
            Priority: Minor


On the solr-user mailing list, Søren reported trying to add a field type via 
the Schema API.  The command partially succeeded by ignoring mistyped params - 
below I reproduced the problem using data_driven_schema_configs:

{noformat}
PROMPT$ curl -X POST http://localhost:8983/solr/gettingstarted/schema -H 
'Content-type: application/json' -d '{
"add-field-type":{
    "name":"myTxtField",
    "class":"solr.TextField",
    "positionIncrementGap":"100",
    "analyzer":{
       "charFilter": {"class":"solr.MappingCharFilterFactory", 
"mapping":"mapping-ISOLatin1Accent.txt"},
       "filter": {"class":"solr.LowerCaseFilterFactory"},
       "tokenizer": {"class":"solr.StandardTokenizerFactory"}
       }
   }
}'
{
  "responseHeader":{
    "status":0,
    "QTime":68}}

PROMPT$ curl 
"http://localhost:8983/solr/gettingstarted/schema/fieldtypes/myTxtField";
{
  "responseHeader":{
    "status":0,
    "QTime":123},
  "fieldType":{
    "name":"myTxtField",
    "class":"solr.TextField",
    "positionIncrementGap":"100",
    "analyzer":{
      "tokenizer":{
        "class":"solr.StandardTokenizerFactory"}},
    "fields":[],
    "dynamicFields":[]}}
{noformat}

Only the tokenizer is included in the field type, because "charFilter" and 
"filter" are misspelled and have the wrong value type: both should be plural 
and should have array values. 

The above request succeeded by ignoring the misspelled params - no charFilter 
or filter was created in the analyzer.  It really should have failed and sent 
back an error explaining the problem.

The following succeeds for me (after first issuing a {{delete-field-type}} 
command and copying {{mapping-ISOLatin1Accent.txt}} into the 
{{gettingstarted/conf/}} directory):

{noformat}
curl -X POST http://localhost:8983/solr/gettingstarted/schema -H 'Content-type: 
application/json' -d '{
"add-field-type":{
    "name":"myTxtField",
    "class":"solr.TextField",
    "positionIncrementGap":"100",
    "analyzer":{
       "charFilters": [{"class":"solr.MappingCharFilterFactory", 
"mapping":"mapping-ISOLatin1Accent.txt"}],
       "tokenizer": {"class":"solr.StandardTokenizerFactory"},
       "filters": [{"class":"solr.LowerCaseFilterFactory"}]
       }
   }
}'
{noformat}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to