# ElasticSearch partial word highlighting with Java API

**URL:** <https://discuss.elastic.co/t/elasticsearch-partial-word-highlighting-with-java-api/41844>\
**Category:** Elasticsearch\
**Created:** [February 16, 2016, 6:12am UTC](https://discuss.elastic.co/t/elasticsearch-partial-word-highlighting-with-java-api/41844 "2016-02-16T06:12:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shivang\_Sarawagi](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@Shivang\_Sarawagi](https://discuss.elastic.co/u/Shivang_Sarawagi)\
**Post date:** [February 16, 2016, 6:12am UTC](https://discuss.elastic.co/t/elasticsearch-partial-word-highlighting-with-java-api/41844/1 "2016-02-16T06:12:26Z")

</div>

I am using elastic search java api version 1.6 in my app for searching data.

I wrote a query for the input search string

```
MatchQueryBuilder qb = QueryBuilders.matchQuery("_all", "search string");
SearchRequestBuilder srb =client.prepareSearch(index);
srb.addHighlightedField("name");
srb.setHighlighterPreTags("<b>");
srb.setHighlighterPostTags("</b>");
srb.setQuery(qb);

```

Below is the JSON query generated

```
{
  "size" : 10,
  "query" : {
    "filtered" : {
      "query" : {
        "match" : {
          "_all" : {
            "query" : "joh",
            "type" : "boolean"
          }
        }
      },
    }
  },
  "fields" : ["name", "address", "level"],
  "highlight" : {
    "pre_tags" : ["<b>"],
    "post_tags" : ["</b>"],
    "fields" : {
      "name" : { }
    }
  }
}

```

I am getting the partial word matches for the input search query string but the highlighting doesn't happen for partial word matches. Only the exact matches are getting highlighted.

Say I enter the word carro & the in the search results I get carrot. I only need the letters `<b>carro</b>t`  
highlighted  
How do I achieve partial highlight matches?

---

<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:16pm UTC](https://discuss.elastic.co/t/elasticsearch-partial-word-highlighting-with-java-api/41844/2 "2017-07-05T23:16:08Z")

</div>


