javascriptelasticsearchmapping

How to fix the mapping structure for Elastic search ? I am trying to migrate from 5.6 to 7.10


Need help with fixing mapping of ES from 5.6 to 7.10

Below is a sample structure. Tried multiple things, but doesnt seem to work, need help.

  "_parent": {
    "type": "brand"
  },
  "properties": {
    "brand": {
      "type": "nested",
      "include_in_parent": true,
      "properties": {
        "encrypted_id": {
          "type": "keyword",
          "store": true
        },
        "name": {
          "type": "text",
          "store": true,
          "fields": {
            "sort": {
              "type": "text",
              "analyzer": "sort_analyzer",
              "fielddata": true
            }
          },
          "analyzer": "stemmer_analyzer"
        }
      }
    }
 }
}

Below is the error message I am getting

Caused by: org.elasticsearch.index.mapper.MapperParsingException: Root mapping definition has unsupported parameters:  [product : {properties={brand={include_in_parent=true, type=nested, properties={encrypted_id={store=true, type=keyword}, name={analyzer=stemmer_analyzer, store=true, type=text, fields={sort={fielddata=true, analyzer=sort_analyzer, type=text}}}}}}}] [company_profile : {properties={modified_ts={format=dateOptionalTime, store=true, ignore_malformed=true, type=date}, company_type={store=true, type=keyword}, country={store=true, type=keyword}, facebook_url={store=true, type=keyword}, account_type={store=true, type=keyword}, featured={include_in_parent=true, type=nested, properties={display_order={store=true, type=long}, event_encrypted_id={store=true, type=keyword}, is_featured={store=true, type=boolean}}}, created_dt={format=dateOptionalTime, store=true, ignore_malformed=true, type=date}, encrypted_id={store=true, type=keyword}, custom_fields={include_in_parent=true, type=nested, properties={buyer_50_fields={type=text, fields={keyword={ignore_above=256, type=keyword}}}, 

Updated:

PUT /test_0001
{
  "mappings": {
    "properties": {
      "brand": {
        "properties": {
          "encrypted_id": {
            "type": "keyword"
          },
          "name": {
            "type": "text",
            "fields": {
              "sort": {
                "type": "keyword"  
              }
            }
          }
        }
      }
    }
  }
}

Error: Below is the error message I am getting

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters:  [brand : {properties={encrypted_id={type=keyword}, name={type=text, fields={sort={type=keyword}}}}}]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [properties]: Root mapping definition has unsupported parameters:  [brand : {properties={encrypted_id={type=keyword}, name={type=text, fields={sort={type=keyword}}}}}]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Root mapping definition has unsupported parameters:  [brand : {properties={encrypted_id={type=keyword}, name={type=text, fields={sort={type=keyword}}}}}]"
    }
  },
  "status": 400
}

The mapping code is of ES 5.6 and the latest one we are using is 7.10

Even after fixing getting the same error

Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [product : {properties={min_msrp={type=double}, is_immediate={type=boolean}, price_visibility_level={type=keyword}, is_published={type=boolean}, display_order={type=long}, description={type=text}, locale={type=keyword}, max_msrp={type=double}, product_images={type=nested, properties={encrypted_id={type=keyword}, name={type=text, fields={sort={type=text}}}}}, msrp_price={type=double}, premium={type=nested, properties={is_premium={type=boolean}, display_order={type=long}}}, company_profile={type=nested, properties={account_type={type=keyword}, encrypted_id={type=keyword}, name={type=text, fields={sort={type=text}}}}}, has_default_sku={type=text}, most_viewed_count={type=long}, price={type=double}, immediate_display_order={type=long}, visibility_level={type=keyword}, company={type=nested, properties={external_checkout_commerce={type=boolean}, allowed_buyer={type=text}, is_connection_requirement_turned_off={type=boolean}, encrypted_id={type=keyword}, subscription_type={type=keyword}, payment_ready={type=boolean}}}, currency={type=keyword}, tag={type=nested, properties={name={type=text, fields={sort={type=text}}}}}, sku={type=text}, stock={type=long}, trackInventory={type=long}, brand={type=nested, properties={encrypted_id={type=keyword}, name={type=text, fields={sort={type=text}}}}}, group={type=nested, properties={cancel_end={format=date_optional_time, type=date}, image={type=nested, properties={encrypted_id={type=keyword}}}, cancel_end_display={format=date_optional_time, type=date}, launch_start={format=date_optional_time, type=date}, encrypted_id={type=keyword}, is_published={type=boolean}, order_end={format=date_optional_time, type=date}, display_order={type=long}, description={type=text}, launch_end_display={format=date_optional_time, type=date}, is_public={type=boolean}, name={type=text, fields={sort={type=text}}}, launch_end={format=date_optional_time, type=date}, delivery_end={format=date_optional_time, type=date}, delivery_start={format=date_optional_time, type=date}, delivery_start_display={format=date_optional_time, type=date}, is_default_product={type=boolean}, order_end_display={format=date_optional_time, type=date}, is_featured={type=boolean}, launch_start_display={format=date_optional_time, type=date}, delivery_end_display={format=date_optional_time, type=date}}}, info={type=nested, properties={definition_id={type=keyword}, display_order={type=long}, id={type=keyword}, label={type=keyword}, type={type=keyword}, value={type=keyword, fields={date={type=date}, number={type=long}, bool={type=boolean}, decimal_number={type=double}, text={type=text}}}, required={type=boolean}}}, company_customfields={type=nested, properties={customfield_id={type=keyword}, customfield_name={type=text}, display_order={type=long}, customfield_value_id={type=keyword}, customfield_value={type=keyword}}}, has_buying_option={type=boolean}, images={type=nested, properties={encrypted_id={type=keyword}, display_order={type=long}, is_default={type=boolean}}}, created_dt={format=date_optional_time, type=date}, encrypted_id={type=keyword}, sku_is_immediate={type=long}, companyprofile_display_order={type=long}, max_price={type=double}, min_price={type=double}, name={type=text, fields={sort={type=text}}}, product_display_order={type=long}, category={type=nested, properties={encrypted_id={type=keyword}, name={type=text, fields={sort={type=text}}}}}, showtoexhibitors={type=keyword}, is_featured={type=boolean},

Solution

  • From 5.6 to 7.10, mapping types have been removed and it is not possible anymore to create several mapping types inside a 7.x index.

    If you want to keep using your custom type name, you can do so by specifying include_type_name=true at index creation time. It will work, but you'll get a deprecation warning in your server logs.

    Also, including a custom type name won't work once you upgrade from 7.10 to 8.x. So you can safely proceed that way for now, but you should remove your custom type name and use the unique and default type name, which is called _doc.