# Highlight does not return anything

**URL:** <https://discuss.elastic.co/t/highlight-does-not-return-anything/21963>\
**Category:** Elasticsearch\
**Created:** [February 3, 2015, 4:48pm UTC](https://discuss.elastic.co/t/highlight-does-not-return-anything/21963 "2015-02-03T16:48:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hao](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@Hao](https://discuss.elastic.co/u/Hao)\
**Post date:** [February 3, 2015, 4:48pm UTC](https://discuss.elastic.co/t/highlight-does-not-return-anything/21963/1 "2015-02-03T16:48:25Z")

</div>

Hi,

I am new to ES and am trying to set up a demo to evaluate if ES works for us as search application. In my demo, I can index and search content of a document eg MS Word or PDF successfully. But I did not manage get highlight work. Highlight field always return nothing even though results have been found.

Can I get some help please?

My environment：

ElasticSearch with attachment plugin  
NEST client is used to talk to ES server (our application is based on .NET) :

I have created two VO : Attachment and Document

public class Attachment  
{  
[ElasticProperty(Name = "\_content", Store = true)]  
public string Content { get; set; }

```
    [ElasticProperty(Name = "_content_type", Store = true),]
    public string ContentType { get; set; }

    [ElasticProperty(Name = "_name", Store = true)]
    public string Name { get; set; }
}

```

[ElasticType(Name = "document")]  
public class Document  
{  
public int Id { set; get; }

```
    [ElasticProperty(Store = true)]
    public string Title { set; get; }

    [ElasticProperty(Type = FieldType.Attachment, TermVector = TermVectorOption.WithPositionsOffsets, Store = true)]
    public Attachment File { set; get; }
}

```

The following methods are used to index and search content of a indexed MS word document:  
private static void IndexWordDoc()  
{  
docElasticClient.CreateIndex(INDEX\_NAME, c =\>  
c.AddMapping(m =\> m.MapFromAttributes().SearchAnalyzer("standard").IndexAnalyzer("standard")));  
var attachment = new Attachment  
{  
Content = Convert.ToBase64String(File.ReadAllBytes(path)),  
ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",  
Name = "SeachTest.docx"  
};  
var doc = new Document()  
{  
Id = 1,  
Title = "SeachTest.docx(title)",  
File = attachment  
};  
docElasticClient.Index(doc);  
}

And search funciton is:

private static ISearchResponse searchMSWord(string term)  
{  
var query = Query.Term("file", term);  
var searchResults = docElasticClient.Search(s =\> s  
.From(0)  
.Size(10)  
.Query(query)  
.Highlight(h=\>h.OnFields(f=\>f.OnField("file")))  
);  
return searchResults;  
}

searchResults can resturn result(s) when I perform a search against indexed document. But Highlight field in the searchResults is always null.

Any idea which part I got it wrong? Thank you

---

<div class="post-metadata">

**Author:** ![Hao](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@Hao](https://discuss.elastic.co/u/Hao)\
**Post date:** [February 3, 2015, 4:53pm UTC](https://discuss.elastic.co/t/highlight-does-not-return-anything/21963/2 "2015-02-03T16:53:04Z")

</div>

By the way, If I only index and search VO(s)，eg I create a simple VO ： Person:

public class Person  
{  
public string FirstName { set; get; }  
public string LastName { set; get; }  
public int Age { set; get; }  
public string About { set; get; }  
}  
}

Highlight works fine if I do the following search:  
private static ISearchResponse SearchVO(string term)  
{  
var searchResults = elasticClient.Search(s =\> s  
.From(0)  
.Size(1000000)  
.Query(q =\> q.Term(p =\> p.About, term))  
.Highlight(h=\>h.PreTags("**").PostTags("**").OnFields(f=\>f.OnField("about").FragmentSize(100)))  
);  
return searchResults;  
}

But it just does not return anything if I search against indexed content of a MS document

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:35am UTC](https://discuss.elastic.co/t/highlight-does-not-return-anything/21963/3 "2017-07-06T00:35:07Z")

</div>


