//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))
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
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
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.
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.
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.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.