0
votes
  • elastisearch version: 7.3.2
  • All documents used there comes from this tutorial.

I have imported from this link a file movies_elastic.json. When I consulted it at: http://localhost:9200/movies/?pretty I received a JSON document for which I give for each key of the document its type and the way to analyze it: keyword, text, long, float, date.

{
  "movies" : {
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "fields" : {
          "properties" : {
            "actors" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "directors" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "genres" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "image_url" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "plot" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "rank" : {
              "type" : "long"
            },
            "rating" : {
              "type" : "float"
            },
            "release_date" : {
              "type" : "date"
            },
            "running_time_secs" : {
              "type" : "long"
            },
            "title" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "year" : {
              "type" : "long"
            }
          }
        },
        "id" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "type" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1568894285856",
        "number_of_shards" : "1",
        "number_of_replicas" : "1",
        "uuid" : "4tvtLNrTRuij4-a0hGBZFQ",
        "version" : {
          "created" : "7030299"
        },
        "provided_name" : "movies"
      }
    }
  }
}

The default mapping of the text in my database includes the keywords "keyword", I now want to transform any field that does not require a raw analysis that allows to take the data as is, without analyzing them.

I tried to load the mapping for the new "movies2" index with:

curl -XPUT -H "Content-Type: application/json" localhost:9200/movies2 -d @mapping_movies/mapping.json

However I get the following error:

JSON
error
root_cause
0
type : "mapper_parsing_exception"
reason : "Root mapping definition has unsupported parameters: [movie : {properties={id={type=text, fields={keyword={ignore_above=256, type=keyword}}}, fields={properties={actors={type=text, fields={raw={index=false, type=text}}}, plot={type=text, fields={keyword={ignore_above=256, type=keyword}}}, release_date={type=date}, year={type=long}, genres={type=text, fields={raw={index=false, type=text}}}, image_url={type=text, fields={raw={index=false, type=text}}}, directors={type=text, fields={raw={index=false, type=text}}}, rating={type=float}, rank={type=long}, title={type=text, fields={keyword={ignore_above=256, type=keyword}}}, running_time_secs={type=long}}}, type={type=text, fields={keyword={ignore_above=256, type=keyword}}}}}]"
type : "mapper_parsing_exception"
reason : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [movie : {properties={id={type=text, fields={keyword={ignore_above=256, type=keyword}}}, fields={properties={actors={type=text, fields={raw={index=false, type=text}}}, plot={type=text, fields={keyword={ignore_above=256, type=keyword}}}, release_date={type=date}, year={type=long}, genres={type=text, fields={raw={index=false, type=text}}}, image_url={type=text, fields={raw={index=false, type=text}}}, directors={type=text, fields={raw={index=false, type=text}}}, rating={type=float}, rank={type=long}, title={type=text, fields={keyword={ignore_above=256, type=keyword}}}, running_time_secs={type=long}}}, type={type=text, fields={keyword={ignore_above=256, type=keyword}}}}}]"
caused_by
type : "mapper_parsing_exception"
reason : "Root mapping definition has unsupported parameters: [movie : {properties={id={type=text, fields={keyword={ignore_above=256, type=keyword}}}, fields={properties={actors={type=text, fields={raw={index=false, type=text}}}, plot={type=text, fields={keyword={ignore_above=256, type=keyword}}}, release_date={type=date}, year={type=long}, genres={type=text, fields={raw={index=false, type=text}}}, image_url={type=text, fields={raw={index=false, type=text}}}, directors={type=text, fields={raw={index=false, type=text}}}, rating={type=float}, rank={type=long}, title={type=text, fields={keyword={ignore_above=256, type=keyword}}}, running_time_secs={type=long}}}, type={type=text, fields={keyword={ignore_above=256, type=keyword}}}}}]"
status : 400

In the mapping below, I changed the type for actors, directors, genres, and URLs. Thus, the fields are indeed text (type), but analyzed as raw data (fields: {raw : {raw : {type : "keyword"}}) :

{
    "mappings" : {
      "movie" : {
        "properties" : {
          "fields" : {
            "properties" : {
              "actors" : {
                "type" : "text",
                "fields" : {
                  "raw" : {
                    "type" : "text",
                    "index" : false
                  }
                }
              },
              "directors" : {
                "type" : "text",
                "fields" : {
                  "raw" : {
                    "type" : "text",
                    "index" : false
                  }
                }
              },
              "genres" : {
                "type" : "text",
                "fields" : {
                  "raw" : {
                    "type" : "text",
                    "index" : false
                  }
                }
              },
              "image_url" : {
                "type" : "text",
                "fields" : {
                  "raw" : {
                    "type" : "text",
                    "index" : false
                    }
                }
              },
              "plot" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "rank" : {
                "type" : "long"
              },
              "rating" : {
                "type" : "float"
              },
              "release_date" : {
                "type" : "date"
              },
              "running_time_secs" : {
                "type" : "long"
              },
              "title" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "year" : {
                "type" : "long"
              }
            }
          },
          "id" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "type" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }
      }
    }
}

My guess is that the commands I tried are not up to date for elastic 7.3.2

Update

I followed Val's counsels and did the following mapping file:

{
    "aliases" : { },
    "mappings" : {

        "properties" : {
          "fields" : {
            "properties" : {
              "actors" : {
                "type" : "text",
                "fields" : {
                  "raw" : {
                    "type" : "text",
                    "index" : false
                  }
                }
              },
              "directors" : {
                "type" : "text",
                "fields" : {
                  "raw" : {
                    "type" : "text",
                    "index" : false
                  }
                }
              },
              "genres" : {
                "type" : "text",
                "fields" : {
                  "raw" : {
                    "type" : "text",
                    "index" : false
                  }
                }
              },
              "image_url" : {
                "type" : "text",
                "fields" : {
                  "raw" : {
                    "type" : "text",
                    "index" : false
                    }
                }
              },
              "plot" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "rank" : {
                "type" : "long"
              },
              "rating" : {
                "type" : "float"
              },
              "release_date" : {
                "type" : "date"
              },
              "running_time_secs" : {
                "type" : "long"
              },
              "title" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "year" : {
                "type" : "long"
              }
            }
          },
          "id" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "type" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }

    }
}

However I wasn't able to import the new data. The following command

curl -XPUT -H "Content-Type: application/json" localhost:9200/_bulk --data-binary @mapping_movies/movies_elastic2.json

gave me the following error :

{
  "took": 44239,
  "errors": true,
  "items": [
    {
      "index": {
        "_index": "movies2",
        "_type": "movie",
        "_id": "1",
        "status": 400,
        "error": {
          "type": "illegal_argument_exception",
          "reason": "Rejecting mapping update to [movies2] as the final mapping would have more than 1 type: [_doc, movie]"
        }
      }
    },
    {
      "index": {
        "_index": "movies2",
        "_type": "movie",
        "_id": "2",
        "status": 400,
        "error": {
          "type": "illegal_argument_exception",
          "reason": "Rejecting mapping update to [movies2] as the final mapping would have more than 1 type: [_doc, movie]"
        }
      }
    },
    {
      "index": {
        "_index": "movies2",
        "_type": "movie",
        "_id": "3",
        "status": 400,
        "error": {
          "type": "illegal_argument_exception",
          "reason": "Rejecting mapping update to [movies2] as the final mapping would have more than 1 type: [_doc, movie]"
        }
      }
    },
    {
      "index": {
        "_index": "movies2",
        "_type": "movie",
        "_id": "4",
        "status": 400,
        "error": {
          "type": "illegal_argument_exception",
          "reason": "Rejecting mapping update to [movies2] as the final mapping would have more than 1 type: [_doc, movie]"
        }
      }
    },
    {
      "index": {
        "_index": "movies2",
        "_type": "movie",
        "_id": "5",
        "status": 400,
        "error": {
          "type": "illegal_argument_exception",
          "reason": "Rejecting mapping update to [movies2] as the final mapping would have more than 1 type: [_doc, movie]"
        }
      }
    },
...
2

2 Answers

0
votes
"Rejecting mapping update to [INDEX] as the final mapping would have more than 1 type: [_doc, TYPE]"

this usually means, the INDEX is already there (with a type, e.g. "movie"), and ES does not allow to add one more type (e.g. "_doc"). So, just remove your index and try again.

0
votes

Your mapping file must look like this:

{
   "aliases" : { },
   "mappings" : {
      "properties" : {
         "fields" : {
            ...

So:

  • remove the top-level movies section
  • remove the movie type

Also note that you cannot define a mapping using the _bulk endpoint, you need to delete the index and recreate it like this:

# delete the index
curl -XDELETE -H "Content-Type: application/json" localhost:9200/movies2

# recreate it
curl -XPUT -H "Content-Type: application/json" localhost:9200/movies2 --data-binary @mapping_movies/movies_elastic2.json

And you're good to go