Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch 6: Rejecting mapping update as the final mapping would have more than 1 type

I'm trying to convert a project to use the latest Elasticsearch 6 and am having this problem. I don't know if the problem is "Product" vs "product". In my mappings and attributes I specify "products", so I am not sure why I get this error when I try to index a product.

Error:

Invalid NEST response built from a unsuccessful low level call on PUT: /products/products/1?pretty=true&error_trace=true

"Rejecting mapping update to [products] as the final mapping would have more than 1 type: [Product, products]"

Request:

{   "id": 1,   "warehouseId": 0,   "productStatus": 1,   "sku": "102377",   "name": "Name",   "shortDescription": "Description",   "longDescription": "Description",   "price": 37.3200 } 

My code:

    [ElasticsearchType(Name = "products")]     public class Product : BaseEntity     {         [Key]         public int Id { get; set; }         public int WarehouseId { get; set; }         [Display(Name = "Product Status")]         public Enums.ProductStatus ProductStatus { get; set; }         [Required, StringLength(10)]         public string Sku { get; set; }         [Required, StringLength(200)]         public string Name { get; set; }         [StringLength(500), Display(Name = "Short Description")]         public string ShortDescription { get; set; }         [DataType(DataType.MultilineText), Display(Name = "Long Description")]         public string LongDescription { get; set; }         [Column(TypeName ="Money")]                     public Nullable<decimal> Price { get; set; }     }  connection.DefaultMappingFor<Product>(m => m.IndexName("products")); 
like image 656
Primico Avatar asked Jun 12 '18 15:06

Primico


People also ask

Can we update mapping in Elasticsearch?

If the Elasticsearch security features are enabled, you must have the manage index privilege for the target data stream, index, or alias. [7.9] If the request targets an index or index alias, you can also update its mapping with the create , create_doc , index , or write index privilege.

How do I delete a map in Elasticsearch?

Elasticsearch is a powerful search engine that makes it easy to delete mapping. To delete mapping, simply use the _delete_mapping API. This will remove the mapping from the index and all of the data associated with it.

What is _type in Elasticsearch?

Basically, a type in Elasticsearch represented a class of similar documents and had a name such as customer or item . Lucene has no concept of document data types, so Elasticsearch would store the type name of each document in a metadata field of a document called _type.


2 Answers

This is because of a breaking change in ES 6.x: mapping types were removed (even if for backward compatibility you can still specify it in the path) thus de facto limiting the index to a single type.

See here for more info.

like image 128
Cavaz Avatar answered Sep 19 '22 13:09

Cavaz


Prior to elasticsearch v6, an index can have only 1 mapping by default. In previous version 5.x, multiple mapping was possible for an index. Though you may change this default setting by updating index setting "index.mapping.single_type": false .

In your case, my assumption is you had already created the index with mapping Product. That is why it was rejecting new mapping in your second request with "product" (p in small case).

like image 31
Prabuddha Chakraborty Avatar answered Sep 22 '22 13:09

Prabuddha Chakraborty