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"));
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.
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.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With