Hi,
I am New to ES, i am trying to index a complete text file in ES. i am using ElasticSearch 2.3.3 with attachment Plugin (mapper-attachement-2.3.3). i am able to index the document(of size 613KB) without any error.
Below are code snippets
public class Document1
{
public Document1()
{
}
public string Title { get; set; }
[Attachment(Name = "file")]
public Attachment File { get; set; }
}
Index creation:
var mappingResponse = client.CreateIndex(index, c => c
.Mappings(m => m
.Map(mm => mm.AutoMap())
)
);
indexing a File.
var attachment = new Attachment();
attachment.Content = Convert.ToBase64String(File.ReadAllBytes(path));
attachment.ContentType = "plain/txt";
attachment.Name = "XA121026_2014_06_09_AXIS_ERR.txt";
var doc = new Document1()
{
Title = "XA121026_2014_06_09_AXIS_ERR.txt",
File = attachment
};
var i = client.Index<Document1>(doc);
and the Mapping looks like
"newindexnesttest":{"mappings":{"document1":{"properties":{"file":{"type":"attachment","fields":{"content":{"type":"string"},"author":{"type":"string"},"title":{"type":"string"},"name":{"type":"string"},"date":{"type":"date","format":"strict_date_optional_time||epoch_millis"},"keywords":{"type":"string"},"content_type":{"type":"string"},"content_length":{"type":"integer"},"language":{"type":"string"}}},"title":{"type":"string"}}}}}}
I have two issues.
-
I am able to search strings until certain part of the documents, for the strings in the middle and end of the documents returns ZERO hits.
-
Highlighting does not work for me.
The Search query is
var queryString1 = "CapUpdateRequest";
var searchRes = client.Search<Document1>(s => s
.From(0)
.Size(10000)
.AllIndices()
.AllTypes()
.Query(qs => qs.QueryString(q => q.Query(queryString1)))
.Highlight(h => h
.PreTags("<b>")
.PostTags("</b>")
.Fields(
f => f.Field(e => e.File)
.PreTags("<em>")
.PostTags("/em>")
)
)
);
Am i missing something, try to get a break from last couple of days.