Attachment is not getting parsed

//using iTextSharp.text;
//using iTextSharp.text.pdf;
using Nest;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication10
{
class Program
{
[ElasticsearchType(Name = "pdfs")]
public class Case
{
public string Author { get; set; }
public string CaseName { get; set; }
[Attachment(Store = true)]
public string attachfile { get; set; }
//[String(Name = "_content_type")]
public string Content { get; set; }
public Case()
{

        }

        //public override string ToString()
        //{
        //    return "Case: " + Author + " - " + File.Name;
        //}
    }


    //public class Attachment
    //{
    //    [String(Name = "_content")]
    //    public string Content { get; set; }

    //    [String(Name = "_content_type")]
    //    public string ContentType { get; set; }

    //    [String(Name = "_name")]
    //    public string Name { get; set; }

    //}
    static void Main(string[] args)
    {
        var index = "pg";
        var node = new Uri("http://localhost:9200");
        var settings = new ConnectionSettings(node).DefaultIndex(index);
        var client = new ElasticClient(settings);



       // var attachment = new Attachment();
        string path = @"C:\Elasticsearch_The Definitive Guide.pdf";
       // attachment.Name = path;
        //attachment.Content = Convert.ToBase64String(File.ReadAllBytes(path));
        
        //Case.ContentType = "application/json";
        //obj.attachfile= Convert.ToBase64String(File.ReadAllBytes(path));
        
        Case obj = new Case();
        obj.Content = Convert.ToBase64String(File.ReadAllBytes(path));
        

        var doc2 = new Case()
        {
            Author = "Martin Luther 2",
            CaseName = "Bank vs Martin",
            attachfile = obj.attachfile


        };

        client.Map<Case>(m => m
.Properties(ps => ps
        .String(s => s
            .Name(f => f.CaseName)
            .Index(FieldIndexOption.Analyzed)
            .Store(true))

.Attachment(atm => atm
.Name(p => p.attachfile)
.FileField(f => f
.Name(p => p.attachfile)
.Index(FieldIndexOption.Analyzed)
.Store(true)
.TermVector(TermVectorOption.WithPositionsOffsets))
.AuthorField(af => af
.Name(p => p.Author)
.Store(true)
.Index(FieldIndexOption.Analyzed)
.TermVector(TermVectorOption.WithPositionsOffsets))))
);

        var indexingthedoc = client.Index<Case>(doc2);
        
        
        Console.Write(indexingthedoc.CallDetails);
        Console.Read();
    }
   
}

}

I am using elasticsearch-5.0.0-alpha2 ES.

Please format your code.

Could you write a curl script which could help to understand?

What is the mapping?
Is the plugin installed?

BTW, as you are using 5.0, prefer using the ingest attachment plugin.

Yes the plugin is installed.I want to use ES-2.3.2 in order to index my pdf file and I want to do text search after mapping is done.

Could you please give me the link to install mapper-attachments plugin zip file for ES-2.3.2..from cmd prompt I am facing issues to install for ES-2.3.2. I have win 7

https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-attachments.html

Verifying https://download.elastic.co/elasticsearch/release/org/elasticsearch/pl
ugin/mapper-attachments/2.3.2/mapper-attachments-2.3.2.zip checksums if availabl
e ...
Downloading .DONE
ERROR: Could not load plugin descriptor for existing plugin [elasticsearch-mappe
r-attachments-2.4.3]. Was the plugin built before 2.0?

I am getting this error, as it is saying the plugin is for 2.0 not for 2.3.2

Thanks it got installed.. I don't know why it was having an issue previously..might be the old version mapping files were there might caused an issue

But again please be aware that this plugin has been deprecated.
It will still exist in 5.0 but will be removed in the future.

I have a class Case which is having Attachment attribute on it's attachfile object

[ElasticsearchType(Name = "pdfs")]
public class Case
{
public int Id { get; set; }
public string Author { get; set; }
public string CaseName { get; set; }
[Attachment(Store = true)]
public string attachfile { get; set; }
public string Content { get; set; }
public Case()
{

        }
    }

This is the Mapping and Indexing I am doing on attachment

client.Map(m => m
.Properties(ps => ps
.String(s => s
.Name(f => f.CaseName)
.Index(FieldIndexOption.Analyzed)
.Store(true))
.Attachment(atm => atm
.Name(p => p.attachfile)
.FileField(f => f
.Name(p => p.attachfile)
.Index(FieldIndexOption.Analyzed)
.Store(true)
.TermVector(TermVectorOption.WithPositionsOffsets))
.AuthorField(af => af
.Name(p => p.Author)
.Store(true)
.Index(FieldIndexOption.Analyzed)
.TermVector(TermVectorOption.WithPositionsOffsets))))
);

        var indexingthedoc = client.Index<Case>(doc2);

But in Sense Beta I am getting an error of parsing.

{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse, document is empty"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse, document is empty"
},
"status": 400
}

If you need help please provide something which is readable and that we can reproduce.
I don't use your coding language so I can't replay / understand it easily.

A curl recreation is more helpful.

I will try to convert in Curl, but I don't have any idea how to write this code in curl

curl -XPUT localhost:9200/pg/pdfs/999

{
"Id": {
"Author" : {
"attachfile" : { "type" : "attachment" }
}

}
}
'

{

"files" : [
{
"_content_type" : "application/pdf",
"_name" : "mypdffile.pdf",
"content" : " ...base64-encoded content.."
}
]
}

The original code I have written in C#.Net and I have used NEST Elasticsearch.Net as a refernced API

Please format your code.

BTW I can't reproduce your example. I have no mapping here.

Even if this is not a full curl script, this example is much more readable: Unable to Find Document, Searching Contents - Mapper Attachments Plugin

@Piyush_Giri, I have opened an issue to make it easier to use the mapper-attachments plugin with NEST.

The plugin is currently supported and tested as part of our CI process (have a look at the integration tests), but more advanced uses require you to write additional code to handle scenarios such as explicit metadata fields and serialization/deserialization of source data into CLR types.

@forloop Thanks russ.. when can we expect the issue #2085 be resolved and plugin can have that fix??