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

Schema API doesn't take class or luceneMatchVersion attributes into account for the analyzer when adding a new field type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 5.2
    • 5.3, 6.0
    • Schema and Analysis
    • None

    Description

      I've noticed that in schema.xml can be defined field types like the following :

          <fieldType name="nametext" class="solr.TextField">
            <analyzer class="org.apache.lucene.analysis.core.WhitespaceAnalyzer"/>
          </fieldType>
      

      The current add-field-type update operation from Schema API doesn't take into account the class (and the luceneMatchVersion - see FieldTypePluginLoader.java) for the field type analyzer definition, but only their type.

      See FieldTypeXmlAdapter.java

        protected static Element createAnalyzerElement(Document doc, String type, Map<String,?> json) {
          Element analyzer = doc.createElement("analyzer");
          if (type != null)
            analyzer.setAttribute("type", type);
            .....
      

      If the change would be made, the add-field-type request would look like this :

      curl -X POST -H 'Content-type:application/json' --data-binary '{
        "add-field-type": {
          "name": "nametext",
          "class": "solr.TextField",
          "analyzer": {
            "class": "org.apache.lucene.analysis.core.WhitespaceAnalyzer"
          }
        }
      }' http://localhost:8983/solr/gettingstarted/schema
      

      Attachments

        1. SOLR-7697.patch
          10 kB
          Steven Rowe
        2. SOLR-7697.patch
          4 kB
          Marius Grama

        Issue Links

          Activity

            People

              sarowe Steven Rowe
              mariusneo Marius Grama
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: