Blog About Me Posts By Tags Subscribe Elastic Search My Sessions Terraform

Pavan Kumar Aryasomayajulu


Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters

Hi, Recently I installed Elastic search 7.0 on one of my machines and I am using NEST C#(6.6.0) Client for interacting with it.

I started getting an exception when trying to create an index from C#.

Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [employee : {properties={office_hours={type=text}, last_name={type=text}, isManager={null_value=false, store=true, type=boolean}, empl={type=nested, properties={}}, salary={coerce=true, ignore_malformed=true, type=float, doc_values=false}, first_name={norms=false, similarity=LMDirichlet, type=text}}}]

Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [employee : {properties={office_hours={type=text}, last_name={type=text}, isManager={null_value=false, store=true, type=boolean}, empl={type=nested, properties={}}, salary={coerce=true, ignore_malformed=true, type=float, doc_values=false}, first_name={norms=false, similarity=LMDirichlet, type=text}}}]

</br> </br>

Class I am trying to automap using Nest

		public class Employee
    {
        public string FirstName { get; set; }

        public string LastName { get; set; }

    }

My auto indexing code:

					
					var nodes = new[]
            {
                new Uri(ConfigurationManager.ConnectionStrings["elasticConnection"].ConnectionString)
            };

            var connectionPool = new StaticConnectionPool(nodes);
            var connectionSettings = new ConnectionSettings(connectionPool);
            var client = new ElasticClient(connectionSettings);
            
            var isIndexExists = client.IndexExists(new IndexExistsRequest("pavan"));
            if (!isIndexExists.Exists)
            {
                var createIndexResponse = client.CreateIndex("pavan", c => c
                    .Mappings(ms => ms.Map<Employee>(m => m.AutoMap())));
            }

Reason For Error:

With Elastic search 7.0 , types were removed and when creating a mapping it no longer accepts types which is a breaking change

Previous syntax for creating a mapping:



PUT wverrors1
{
  "mappings": {
    "_doc": {
      "properties": {
        "date": {
          "type":   "date",
          "format": "yyyy-MM-dd HH:mm:ss"
        }
      }
    }
  }
}

But this no longer work’s and we need to remove _doc which is the type.

This is working syntax

PUT wverrors1
{
  "mappings": {
      "properties": {
        "date": {
          "type":   "date",
          "format": "yyyy-MM-dd HH:mm:ss"
        }
      }
  }
}

Reference Urls: https://www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html

Fix From Nest side:

As of now,from Nest side there is no alternative ( You can make use of the beta package available at https://ci.appveyor.com/nuget/elasticsearch-net) and I hope they will release a new version soon i Nugent to fix this issue and other breaking changes

There is an open issue from Nest side

https://github.com/elastic/elasticsearch-net/issues/3663

Installing 7.0 Beta Nest Package

If you still want to try Elastic search 7.0 with with Nest then you can try beta package available at https://ci.appveyor.com/nuget/elasticsearch-net

Below are steps for installing the beta version from appveyor

Step 1:: In Visual Studio Nuget packages window you can see a gear icon next to Package Source dropdown. Click that gear icon



**Step2: **In the option popup there is a menu item “Nuget Package Manager”… Under that we can see “Package Source”

Step3: Click on Plus icon (+)… Now in the source for new item give this url https://ci.appveyor.com/nuget/elasticsearch-net and click on ok



**Step4 : **Now In Nugent Package window for package source select the newly added one from dropdown



Step5: Also make sure that you check “Include Prerelease”, In the package manager window

Step5:: Now when we try to install Nest package, we will see “7.1.0-ci20190412T075554” prerelease version. and we can install it now.


Thanks,
Pavan Kumar Aryasomayajulu

Keywords: Nest C# Client, Elastic search 7.0

#ElasticSearch #Nest