Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-30539

Add a way to contribute a custom elastic mapping

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 2021.x
    • Component/s: Elasticsearch
    • Release Notes Summary:
      Allow for the contribution of additional ElasticSearch mappings.
    • Release Notes Description:
      Hide

      It is now possible to contribute additional ElasticSearch mappings to be merged with existing mappings instead of overriding the entire mapping with each new contribution.
      To add an additional JSON mapping:

      <?xml version="1.0"?>
      <component name="org.nuxeo.elasticsearch.test.append.true.mapping.without.mappingfile.contrib">
        <extension point="elasticSearchIndex" target="org.nuxeo.elasticsearch.ElasticSearchComponent">
          <elasticSearchIndex name="nxutest">
            <mapping append="true">
              {
                "properties": {
                  "ecm:name": {
                    "type": "keyword",
                    "ignore_above": 256,
                    "copy_to": "all_field"
                  }
                }
              }
            </mapping>
          </elasticSearchIndex>
        </extension>
      </component> 

      To add an additional mapping file:

      <?xml version="1.0"?>
      <component name="org.nuxeo.elasticsearch.test.append.true.mapping.with.mappingfile.contrib">
        <extension point="elasticSearchIndex" target="org.nuxeo.elasticsearch.ElasticSearchComponent">
          <elasticSearchIndex name="nxutest">
            <mapping file="append-true-mapping-with-mappingfile.json" append="true" />
          </elasticSearchIndex>
        </extension>
      </component>
      

      JSON file :

      {
        "properties": {
          "ecm:name": {
            "type": "keyword",
            "ignore_above": 256,
            "copy_to": "all_field"
          }
        }
      }
      

      The append="true" property must be set in order for mappings to be merged, if append="false" or the field is unused, the existing mapping will be overridden.

      Show
      It is now possible to contribute additional ElasticSearch mappings to be merged with existing mappings instead of overriding the entire mapping with each new contribution. To add an additional JSON mapping: <?xml version= "1.0" ?> <component name= "org.nuxeo.elasticsearch.test.append.true.mapping.without.mappingfile.contrib" > <extension point= "elasticSearchIndex" target= "org.nuxeo.elasticsearch.ElasticSearchComponent" > <elasticSearchIndex name= "nxutest" > <mapping append= "true" > { "properties" : { "ecm:name" : { "type" : "keyword" , "ignore_above" : 256, "copy_to" : "all_field" } } } </mapping> </elasticSearchIndex> </extension> </component> To add an additional mapping file: <?xml version= "1.0" ?> <component name= "org.nuxeo.elasticsearch.test.append.true.mapping.with.mappingfile.contrib" > <extension point= "elasticSearchIndex" target= "org.nuxeo.elasticsearch.ElasticSearchComponent" > <elasticSearchIndex name= "nxutest" > <mapping file= "append-true-mapping-with-mappingfile.json" append= "true" /> </elasticSearchIndex> </extension> </component> JSON file : { "properties" : { "ecm:name" : { "type" : "keyword" , "ignore_above" : 256, "copy_to" : "all_field" } } } The append="true" property must be set in order for mappings to be merged, if append="false" or the field is unused, the existing mapping will be overridden.
    • Team:
      PLATFORM
    • Sprint:
      nxplatform #49, nxplatform #50, nxplatform #51, nxplatform #52, nxplatform #53, nxplatform #54, nxplatform #55
    • Story Points:
      1

      Description

      We want to contribute an elastic JSON mapping from any component.

      The existing endpoint will collect the list of JSON mappings, for instance, we can have:

        <require>org.nuxeo.elasticsearch.defaultConfig</require>
      
        <extension target="org.nuxeo.elasticsearch.ElasticSearchComponent" point="elasticSearchIndex">
          <elasticSearchIndex name="${elasticsearch.indexName}">
            <mapping file="elasticsearch-doc-my-custom-mapping.json" />
          </elasticSearchIndex>
        </extension>
      

      When creating the index the mapping will be applied in the order using multiple updates.
      We let elastic performs the merge and resolves the conflict :crossfingers:.

      We could do the same logic for settings.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: