# Hithighlighting boolean query including exact phrase words

**URL:** <https://discuss.elastic.co/t/hithighlighting-boolean-query-including-exact-phrase-words/133518>\
**Category:** Elasticsearch\
**Created:** [May 28, 2018, 10:36am UTC](https://discuss.elastic.co/t/hithighlighting-boolean-query-including-exact-phrase-words/133518 "2018-05-28T10:36:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hardik.hbs](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@Hardik.hbs](https://discuss.elastic.co/u/Hardik.hbs)\
**Post date:** [May 28, 2018, 10:36am UTC](https://discuss.elastic.co/t/hithighlighting-boolean-query-including-exact-phrase-words/133518/1 "2018-05-28T10:36:37Z")

</div>

Hi,

We are using ElasticSearch with version 2.4.

When we do search in a field for query as below in a field, it is not highlighting the complete phrase word.

(Google OR Bing) AND "SQL Developer"

The above query gives result properly, but if we use it with Hit-highlighting, it highlights not only Google and Bing, but it also consider the both SQL and Developer as separate words and highlight them separately instead of highlighting only exact phrase "SQL Developer" .

Below is the C# code, we are using for the same.

string keyword = @"(Google OR Bing) AND "SQL Developer"";  
var filterQueries = new List\<Func\<QueryContainerDescriptor, QueryContainer\>\>();  
filterQueries.Add(m2 =\>  
m2.QueryString(m3 =\> m3.Fields("Note").Query(Keyword)));

ISearchResponse result = client.Search(S =\> S.From(0)  
.Size(20)  
.MatchAll()  
.Query(q =\> q  
.Bool(b =\> b  
.Filter(filterQueries)  
))  
.Highlight(h =\> h  
.Fields(  
fs =\> fs  
.Field(p =\> p.Note)  
.Type(HighlighterType.Plain)  
.ForceSource()  
.FragmentSize(fs1)  
.NumberOfFragments(noF)  
)  
.PreTags("**")  
.PostTags("**")  
)  
);

Please help me if we are missing out any thing in query code.

Thanks  
Hardik

---

<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:** [June 25, 2018, 10:36am UTC](https://discuss.elastic.co/t/hithighlighting-boolean-query-including-exact-phrase-words/133518/2 "2018-06-25T10:36:38Z")

</div>

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