这是我的发帖方式

[HttpPost]
    public IActionResult InsertEmployee([FromForm]Employee model)
    {


        var Employee = new Employee
        {
            EmpId = 3,
            Name = "asadasasad",
            Country = "pak",
            Gender = false,
            StartDate = DateTime.Now.Date,
            MultiCheck = "3,2,1"
        };

        PostData fromObject = PostData.Serializable(Employee);
        _elasticClient.Index(fromObject, i => i
               .Index("employee"));

        string message = "Failed to create the product. Please try again";
        return Content(message);
    }
使用此方法时,它会增加值,但不会显示在记录中
http:// localhost:9200 / employee / _search?typed_keys = true?size = 1000
该查询返回此响应
c# - ElasticSearch PostData序列化插入不起作用-LMLPHP

最佳答案

在Elastic Search Post Data insert中,您首先需要序列化对象,该对象将其转储到类中,然后反序列化,然后使用这种方式插入elasticsearch中

                        var data = JsonConvert.DeserializeObject<NetConnectTransactionDTO>(deserialize);
                        var Response = _elasticClient.Index(data, i => i
                          .Index(NetConnectTransactionIndex));

10-07 12:08
查看更多