Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0, 6.0
    • Component/s: Schema and Analysis
    • Labels:
      None

      Description

      POST to /schema/fieldtypes will add one or more new field types to the schema.

      PUT to /schema/fieldtypes/name will add the name'd field type to the schema.

      1. SOLR-5098.patch
        61 kB
        Timothy Potter
      2. SOLR-5098.patch
        44 kB
        Timothy Potter
      3. SOLR-5098.patch
        36 kB
        Timothy Potter

        Activity

        Hide
        Timothy Potter added a comment -

        Here is a first cut at support for adding new field types to managed schema. Two things of interest here:

        1) There's a whole bunch of proven code for creating a fieldType using the FieldTypePluginLoader so I chose to use that for this solution. However, it requires the fieldType to be defined in XML, hence this patch uses an "adapter" to transform the JSON from the REST API request to XML, see: FieldTypeXmlAdapter (only around 100 lines of shim code)

        2) The endpoint doesn't support adding multiple field types in a single request as is allowed for fields. Personally, I think client apps should have to add one field type at a time, but if we want to allow multiple that shouldn't be too bad to add.

        Show
        Timothy Potter added a comment - Here is a first cut at support for adding new field types to managed schema. Two things of interest here: 1) There's a whole bunch of proven code for creating a fieldType using the FieldTypePluginLoader so I chose to use that for this solution. However, it requires the fieldType to be defined in XML, hence this patch uses an "adapter" to transform the JSON from the REST API request to XML, see: FieldTypeXmlAdapter (only around 100 lines of shim code) 2) The endpoint doesn't support adding multiple field types in a single request as is allowed for fields. Personally, I think client apps should have to add one field type at a time, but if we want to allow multiple that shouldn't be too bad to add.
        Hide
        Timothy Potter added a comment -

        Updated patch with ability to add multiple field types at once like the fields API allows.

        I'm ready to commit this one to production - planning to do that on Monday if no additional feedback.

        Show
        Timothy Potter added a comment - Updated patch with ability to add multiple field types at once like the fields API allows. I'm ready to commit this one to production - planning to do that on Monday if no additional feedback.
        Hide
        Steve Rowe added a comment -

        Tim, looks great - I did a quick review and noticed a few things:

        1. ManagedIndexSchema, the addFieldType(), addFieldTypes() and newFieldType() methods should extend (no-op) methods in IndexSchema, like the addField(), addFields() and newField() methods do.
        2. Multi-term analyzers aren't handled in ManagedIndexSchema.addFieldTypes() - you have to cast to TextField to access this analyzer if it's defined.
        3. It's a little weird that FieldTypeCollectionResource.addOrUpdateFieldTypes() calls FieldTypeResource.addNewFieldTypes() - that piece of code is fairly small, converting addNewFieldTypes() to specialized non-statics might be better?
        4. FieldTypeCollectionResource should implement POSTable, and FieldTypeResource should implement PUTable.
        5. The licence text in TestManagedSchemaFieldTypeResource is a copy-paste of the one in TestFieldTypeResource, where I added spaces where they don't belong on the last line: "limit ations".
        6. In addition to testing creation of field types, TestManagedSchemaFieldTypeResource should also test creating fields using newly created field types.
        7. TestCloudManagedSchemaConcurrent should be modified to include some field type additions; this class will need some love every time we add new functionality to the schema API.
        Show
        Steve Rowe added a comment - Tim, looks great - I did a quick review and noticed a few things: ManagedIndexSchema , the addFieldType() , addFieldTypes() and newFieldType() methods should extend (no-op) methods in IndexSchema , like the addField() , addFields() and newField() methods do. Multi-term analyzers aren't handled in ManagedIndexSchema.addFieldTypes() - you have to cast to TextField to access this analyzer if it's defined. It's a little weird that FieldTypeCollectionResource.addOrUpdateFieldTypes() calls FieldTypeResource.addNewFieldTypes() - that piece of code is fairly small, converting addNewFieldTypes() to specialized non-statics might be better? FieldTypeCollectionResource should implement POSTable , and FieldTypeResource should implement PUTable . The licence text in TestManagedSchemaFieldTypeResource is a copy-paste of the one in TestFieldTypeResource , where I added spaces where they don't belong on the last line: "limit ations". In addition to testing creation of field types, TestManagedSchemaFieldTypeResource should also test creating fields using newly created field types. TestCloudManagedSchemaConcurrent should be modified to include some field type additions; this class will need some love every time we add new functionality to the schema API.
        Hide
        ASF subversion and git services added a comment -

        Commit 1622724 from Timothy Potter in branch 'dev/trunk'
        [ https://svn.apache.org/r1622724 ]

        SOLR-5098: Support adding field types to managed schema

        Show
        ASF subversion and git services added a comment - Commit 1622724 from Timothy Potter in branch 'dev/trunk' [ https://svn.apache.org/r1622724 ] SOLR-5098 : Support adding field types to managed schema
        Hide
        ASF subversion and git services added a comment -

        Commit 1624057 from Timothy Potter in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1624057 ]

        SOLR-5098: backport from trunk to branch4x

        Show
        ASF subversion and git services added a comment - Commit 1624057 from Timothy Potter in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1624057 ] SOLR-5098 : backport from trunk to branch4x
        Hide
        Timothy Potter added a comment -

        Here's the patch of what was committed to trunk and branch_4x

        Show
        Timothy Potter added a comment - Here's the patch of what was committed to trunk and branch_4x
        Hide
        ASF subversion and git services added a comment -

        Commit 1624098 from Timothy Potter in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1624098 ]

        SOLR-5098: fix eol-style

        Show
        ASF subversion and git services added a comment - Commit 1624098 from Timothy Potter in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1624098 ] SOLR-5098 : fix eol-style
        Hide
        Anshum Gupta added a comment -

        Bulk close after 5.0 release.

        Show
        Anshum Gupta added a comment - Bulk close after 5.0 release.

          People

          • Assignee:
            Timothy Potter
            Reporter:
            Steve Rowe
          • Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development