# Highlight query not returning expected results

**URL:** <https://discuss.elastic.co/t/highlight-query-not-returning-expected-results/90044>\
**Category:** Elasticsearch\
**Created:** [June 20, 2017, 6:27am UTC](https://discuss.elastic.co/t/highlight-query-not-returning-expected-results/90044 "2017-06-20T06:27:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshraddha](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jshraddha](https://discuss.elastic.co/u/jshraddha)\
**Post date:** [June 20, 2017, 6:27am UTC](https://discuss.elastic.co/t/highlight-query-not-returning-expected-results/90044/1 "2017-06-20T06:27:16Z")

</div>

Hi,

I am searching a particular word using highlight query.  
I am using two different queries  
1.  
`body: { query: { match_phrase: { "attachment.content": searchedWord } }, highlight : { order : "score", require_field_match: false, fields : { "attachment.content" : { } } } }`

1. Another is  
`body: { "_source": false, query: { "bool": { "must": [{"terms": {"_id":[id]}} ], "should": { "match": {"attachment.content": searchedWord}} } }, "highlight" : { "pre_tags":"<mark>", "post_tags":"</mark>", "fields" : { "attachment.content" : { "number_of_fragments" : 0 } } } }`

Thing is that if I search for a word let say for example "exchange" So basically in my document this word appears for 11 times. My first query returns me 6 fragments  
whereas when I run my next query with **number\_of\_fragments: 0** I get all the 11 results with my pre and post tags

What should I do so that I will get all the 11 searches as 11 fragments in my first query?

---

<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 18, 2017, 6:27am UTC](https://discuss.elastic.co/t/highlight-query-not-returning-expected-results/90044/2 "2017-07-18T06:27:39Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
