# Highlighting Boundary characters are not working in elastic search 1.7.1

**URL:** <https://discuss.elastic.co/t/highlighting-boundary-characters-are-not-working-in-elastic-search-1-7-1/34814>\
**Category:** Elasticsearch\
**Created:** [November 17, 2015, 2:39pm UTC](https://discuss.elastic.co/t/highlighting-boundary-characters-are-not-working-in-elastic-search-1-7-1/34814 "2015-11-17T14:39:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![himanshu.arora](https://avatars.discourse-cdn.com/v4/letter/h/4af34b/32.png) [@himanshu.arora](https://discuss.elastic.co/u/himanshu.arora)\
**Post date:** [November 17, 2015, 2:39pm UTC](https://discuss.elastic.co/t/highlighting-boundary-characters-are-not-working-in-elastic-search-1-7-1/34814/1 "2015-11-17T14:39:17Z")

</div>

Hi Team,

I am using elastic search and Java API version 1.7.1. I have a simple highlighting problem with boundary characters  
Here I am setting the source content with

```
	XContentBuilder source = jsonBuilder().startObject();
	source.field(PROPERTY_BOOK_ID, bookId)
	.field(PROPERTY_CONTENT, parsedContent)
	.field("term_vector", "with_positions_offsets")
	.field(PROPERTY_FILENAME, file.getName())
	.field(PROPERTY_ATTACHMENT, Base64.encodeBase64String(FileUtils.readFileToByteArray(file)));

```

As per the documentation boundary characters work with **term\_vector", "with\_positions\_offsets**

But When I query to the elastic search with boundary characters its giving me wrong response. Here is my Search Query with the search content "poem"

```
QueryBuilder query = boolQuery().must(QueryBuilders.textPhraseQuery(PROPERTY_BOOK_ID, bookId))
			 .must(QueryBuilders.queryStringQuery("*"+searchTerm+"*"));
	
	Map<String, Object> highlighterOptions = new HashMap<>();
	highlighterOptions.put("boundary_chars", "s.,!?\\t\\n\b");
	
	final SearchResponse response = searchClientService.getClient()
			.prepareSearch(INDEX_NAME).setTypes(INDEX_TYPE)
            .setHighlighterQuery(query)
            .addHighlightedField(PROPERTY_CONTENT)
            .setHighlighterOptions(highlighterOptions)
			.setExplain(true)
            .setSize(5000)
            .setFrom(0)
            .setHighlighterBoundaryMaxScan(10)
            .setHighlighterFragmentSize(50)
            .setHighlighterNumOfFragments(5000)
            .execute().actionGet();

```

Result :  
0)English Literature poetry book, with _poems_ from leading  
1)you will

enjoy these _poems_ during your GCSE  
2)course and later in life.

Many of the _poems_ deal  
3). There are _poems_ that will reflect your own ideas  
4)you make the most of the _poems_ and of your GCSE. It  
5)in writing about and comparing _poems_ for GCSE  
6)you today.

_Poems_ past and present – the AQA

Expected :  
0)English Literature poetry book, with _poems_ from leading  
1)enjoy these _poems_ during your GCSE  
2)Many of the _poems_ deal  
3)There are _poems_ that will reflect your own ideas  
4)you make the most of the _poems_ and of your GCSE.  
5)in writing about and comparing _poems_ for GCSE  
6)_Poems_ past and present – the AQA

Did I miss something in the query or while indexing the document ? Or did I misunderstand the boundary characters concept that the returned excerpts from elastic search returns above expected result ?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![himanshu.arora](https://avatars.discourse-cdn.com/v4/letter/h/4af34b/32.png) [@himanshu.arora](https://discuss.elastic.co/u/himanshu.arora)\
**Post date:** [November 18, 2015, 4:40am UTC](https://discuss.elastic.co/t/highlighting-boundary-characters-are-not-working-in-elastic-search-1-7-1/34814/2 "2015-11-18T04:40:03Z")

</div>

Experts, Please help

---

<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 5, 2017, 11:37pm UTC](https://discuss.elastic.co/t/highlighting-boundary-characters-are-not-working-in-elastic-search-1-7-1/34814/3 "2017-07-05T23:37:47Z")

</div>


