# Global highlighting settings not available in the Java API?

**URL:** https://discuss.elastic.co/t/global-highlighting-settings-not-available-in-the-java-api/16059
**Category:** Elasticsearch
**Created:** [February 27, 2014, 8:37pm UTC](https://discuss.elastic.co/t/global-highlighting-settings-not-available-in-the-java-api/16059 "2014-02-27T20:37:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![seallison](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@seallison](https://discuss.elastic.co/u/seallison)
#### Post date: [February 27, 2014, 8:37pm UTC](https://discuss.elastic.co/t/global-highlighting-settings-not-available-in-the-java-api/16059/1 "2014-02-27T20:37:36Z")

</div>

I'm trying to set the global highlighting settings through the Java API for  
"fragment\_size" and "number\_of\_fragments" as documented here:

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-highlighting.html#highlighting-settings](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-highlighting.html#highlighting-settings)

I don't see anything in SearchRequestBuilder that lets me configure those  
settings. I'm working around this by setting them for each field using the  
method:

searchRequestBuilder.addHighlightedField(name, fragmentSize,  
numberOfFragments)

How can I configure these two settings globally for the highlighter? If it  
matters, I'm using 0.90.11.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8a43a1f7-c99a-49c1-afd0-bf0de05df62c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8a43a1f7-c99a-49c1-afd0-bf0de05df62c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)
#### Post date: [February 27, 2014, 8:56pm UTC](https://discuss.elastic.co/t/global-highlighting-settings-not-available-in-the-java-api/16059/2 "2014-02-27T20:56:20Z")

</div>

The link to the corresponding documentation for version 0.90.XX is here:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

I was thinking that perhaps 0.90 did not include them, but they are also  
listed in that version documentation also.

Since I haven't yet used highlighting, I will lurk on this thread and may  
learn something!

Brian

> 

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7aeff853-621f-4d2d-96fe-9b671752c4e4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7aeff853-621f-4d2d-96fe-9b671752c4e4%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)
#### Post date: [February 27, 2014, 10:06pm UTC](https://discuss.elastic.co/t/global-highlighting-settings-not-available-in-the-java-api/16059/3 "2014-02-27T22:06:36Z")

</div>

Just a quick untested look at the code, but you might want to try:

SearchRequestBuilder.setHighlighterOptions(options);

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e590c392-64fb-4c81-8f39-e420630f513b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e590c392-64fb-4c81-8f39-e420630f513b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![seallison](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@seallison](https://discuss.elastic.co/u/seallison)
#### Post date: [February 27, 2014, 10:11pm UTC](https://discuss.elastic.co/t/global-highlighting-settings-not-available-in-the-java-api/16059/4 "2014-02-27T22:11:50Z")

</div>

Yeah I tried that too:

Map\<String, Object\> options = new HashMap\<String, Object\>();  
options.put("fragment\_size", 0);  
options.put("number\_of\_fragments", 0);  
searchRequestBuilder.setHighlighterOptions(options);

but the query ends up looking like this:

"highlight" : {  
"options" : {  
"number\_of\_fragments" : 0,  
"fragment\_size" : 0  
},...

On Thursday, February 27, 2014 5:06:36 PM UTC-5, Binh Ly wrote:

> Just a quick untested look at the code, but you might want to try:
> 
> SearchRequestBuilder.setHighlighterOptions(options);

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/034a9182-3160-471d-8e82-a8fd23509c19%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/034a9182-3160-471d-8e82-a8fd23509c19%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)
#### Post date: [February 27, 2014, 10:41pm UTC](https://discuss.elastic.co/t/global-highlighting-settings-not-available-in-the-java-api/16059/5 "2014-02-27T22:41:43Z")

</div>

I took a closer look and indeed you are correct, the REST API actually has  
some logic in there to trickle it down to the fields level (which I didn't  
expect). Can you please open a ticket?

In the meantime, I'd probably just fall back to .setSource() if absolutely  
needed. Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f4e124b8-5102-4e7e-9ca1-592b04651991%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f4e124b8-5102-4e7e-9ca1-592b04651991%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![seallison](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@seallison](https://discuss.elastic.co/u/seallison)
#### Post date: [February 27, 2014, 10:49pm UTC](https://discuss.elastic.co/t/global-highlighting-settings-not-available-in-the-java-api/16059/6 "2014-02-27T22:49:14Z")

</div>

Thanks for your confirmation! I've opened a  
ticket: [Java API does not have a way to set global highlighting settings · Issue #5281 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/5281)

On Thursday, February 27, 2014 5:41:43 PM UTC-5, Binh Ly wrote:

> I took a closer look and indeed you are correct, the REST API actually has  
> some logic in there to trickle it down to the fields level (which I didn't  
> expect). Can you please open a ticket?
> 
> In the meantime, I'd probably just fall back to .setSource() if absolutely  
> needed. Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f1376590-62ca-4e41-bc50-fb45b4c0e551%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f1376590-62ca-4e41-bc50-fb45b4c0e551%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:46am UTC](https://discuss.elastic.co/t/global-highlighting-settings-not-available-in-the-java-api/16059/7 "2017-07-06T01:46:45Z")

</div>


