Mapper Plugin Issues


(Deepikaa Subramaniam) #1

I am using ElasticSearch mapper plugin for indexing contents for pdf, xls,
ppt file types. My mapping is as follows:

[ElasticType(
    Name = "IndexDocument",
    SearchAnalyzer = "standard",
    IndexAnalyzer = "standard",
    DateDetection = true,
    NumericDetection = true
)]
public class Document
{
    public string id { get; set; }
    [ElasticProperty(Type = Nest.FieldType.attachment, Store = false, TermVector = Nest.TermVectorOption.with_positions_offsets)]
    public ESAttachment esAttachment { get; set; }
}

public class ESAttachment
{
    public string _content_type { get; set; }
    public string _name { get; set; }
    public string content { get; set; }
}

Here is the code for indexing:

    esClient.MapFromAttributes<Document>();

    var item = new Document();
    item.esAttachment = new ESAttachment();
    item.esAttachment._content_type = "application/pdf";
    item.esAttachment.content = Convert.ToBase64String(System.IO.File.ReadAllBytes(file));
    item.esAttachment._name = "test-pdf";

    List<Document> bulkDoc = new List<Document>();
    bulkDoc.Add(item);

    var des = new BulkDescriptor();
    foreach (var doc in bulkDoc)
    {
        des.Index<Document>(j => j.Object(doc).Index("indexname"));
    }

    var status = esClient.BulkAsync(des);

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/45e6937d-9553-40ed-bc23-02a84d7f3d3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2