简体   繁体   English

Elasticsearch Nest不插入文档

[英]Elasticsearch Nest doesn't insert document

I have two POCO types PdfIndex and PieceEM: 我有两种POCO类型 PdfIndex和PieceEM:

 public class PdfIndex
 {
    public string Path { get; set; }
    public PieceEM Pdf { get; set; }
 }

And PieceEM: 和PieceEM:

public class PieceEM
{
    public string Id { get; set; }
    public string Content { get; set; }
    public string Language { get; set; }
    public string Profession { get; set; }
    public string DeparmentOfPiece { get; set; }
    public string PieceType { get; set; }
    public string PricingType { get; set; }
    public string PieceId { get; set; }
    public string Author { get; set; }
}

All pdfs read and but not indexed. 所有pdf均已阅读但未编入索引。 The code does not fail, just this address has no data http://localhost:9200/fullegalpieces/_search?pretty=true 代码不会失败,仅此地址没有数据http:// localhost:9200 / fullegalpieces / _search?pretty = true

This is my index code: 这是我的索引代码:

public void IndexPiece(IEnumerable<PdfIndex> pdfIndexes)
    {
        foreach (var pdfIndex in pdfIndexes)
        {
            if (!File.Exists(pdfIndex.Path)) continue;

            var pdfReader = new PdfReader(pdfIndex.Path);
            string text = string.Empty;
            for (int page = 1; page <= pdfReader.NumberOfPages; page++)
            {
                text += PdfTextExtractor.GetTextFromPage(pdfReader, page);
            }
            pdfReader.Close();

            PieceEM _pdf = pdfIndex.Pdf;
            _pdf.Content = IndexDocumentHelper.RemoveSpecialChar(text);
            _pdf.Content += _pdf.Author;

            _elasticClient.Index(_pdf, i => i
            .Type<PieceEM>());
        }
    }

Path is correct. 路径正确。 This pdf exists locally, and my post action is here: 该pdf文件在本地存在,我的发布动作在此处:

     [HttpPost]
    public void IndexPiece(List<PdfIndex> pdfIndexes)
    {
        var elastic = new ElasticHelper.ElasticSearchHelper("http://localhost:9200/", "fullegalpieces");
        elastic.IndexPiece(new List<PdfIndex> {
            new PdfIndex
            {
                Path = @"C:\Users\Yılmaz\Desktop\özgeçmiş.pdf",
                Pdf = new PieceEM
                {
                    Id = "042f01f8-befc-40a7-9339-fa4fffe2c4e0",
                    PieceId = "bd7aaa9c-7c81-4675-a037-0fa56ad09003",
                    Language = "1",
                    PieceType ="2",
                    PricingType = "1",
                    Profession = "1",
                    Author = "ykaraagac",
                    DeparmentOfPiece = "1"
                }
            }
        });


    }

I have similar examples, but this does not work. 我有类似的例子,但这是行不通的。 What can I do? 我能做什么?

Thanks. 谢谢。

i checked my local log file and i saw this: 我检查了本地日志文件,然后看到了:

i indexed different POCO type, not PieceEM 我索引了不同的POCO类型,而不是PieceEM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM