Does not contain a definition for 'Type' in ASP.NET MVC Elasticsearch

I want to create a search on "user" index with ASP.NET MVC. DataSearch Action Method:

public JsonResult DataSearch(string name)  
    {  
        var responsedata = _connectionToEs.EsClient().Search<User>(s => s  
                                .Index("user")  
                                .Type("doc")  
                                .Size(50)  
                                .Query(q => q  
                                    .Match(m => m  
                                        .Field(f => f.name)  
                                        .Query(name)  
                                    )  
                                )  
                            );  
  
        var datasend = (from hits in responsedata.Hits  
                        select hits.Source).ToList();  
  
        return Json(new { datasend, responsedata.Took }, behavior: JsonRequestBehavior.AllowGet);  
    } 

I got error in .Type("doc"). Severity Code Description Project File Line Suppression State Error CS1061 'SearchDescriptor' does not contain a definition for 'Type' and no accessible extension method 'Type' accepting a first argument of type 'SearchDescriptor' could be found (are you missing a using directive or an assembly reference?). I already added using Elasticsearch.Net; using Nest; using Newtonsoft.Json;. How to fix this problem? Thanks

It sounds like you're using a NEST 7.x version; NEST 7.x does not contain a .Type() method as types are deprecated in Elasticsearch and will be removed entirely in a future version.

You can remove the .Type() method call; the default document "type" will be _doc.