Java API Highlighting

I'm new to Elasticsearch and I have two questions. I've done quite a bit of
Google searching and looked at the Elasticsearch tests for guidance, but
I'm not getting the desired result.

I'm querying an Elasticsearch server I don't control, but the index seems
straight forward enough. When I query it via the Java API however, I cannot
get highlights to work. My code looks more or less like this:

SearchRequestBuilder builder = client.prepareSearch(SEARCH_INDEX)

I get back results, but I don't get back a "highlight" collection. I get
back this instead:

"highlightFields": {
"content": {
"name": "content",
"fragments": [
"title": {
"name": "title",
"fragments": [

In other words, it seems like it wanted to find fragments, but it gave me
blank results. Thinking maybe it was something wrong with the index, I
POSTed this to the server:

{ "highlight" : { "fields" : { "content" : {} }
, "fields": ["title", "_id", "subject", "uri", "dateEffective"]

And got the expected results:

"highlight": {
"content": [
" fuel transfer pump operation,
\r\ninstall Javelin Placard 782-14 or an equivalent FAA-approved
"73-17-01 CESSNA: Amdt. 39-1701.
Applies to all series of Cessna Models 170, \r\n172, 175, 180 and"
", adjacent \r\nto the fuel transfer pump
switch which reads as follows: "AUXILIARY FUEL \r\nTRANSFER PUMP",
BEFORE CHANGING FROM LEFT \r\nTANK." \r\n\r\n\tNOTE: Failure to turn",
" off fuel boost pump allows air to enter
engine \r\nfuel system and may cause engine power failure when"

It's obvious I'm doing something wrong in the API, but I can't seem to get
it to perform the highlighting I want. Any help?

This leads me to my second question. When trying to debug this, I wanted to
view the "source" or JSON of the request being sent to Elasticsearch so I
could compare but I couldn't find a method for this. I resorted to sniffing
my traffic with Wireshark, but it was not very efficient for viewing what I
was sending to the server.

Is there a log level or something I can set in the Java API?


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
To view this discussion on the web visit
For more options, visit

You have probably found an answer to your question. But it seems there is little here about examples for the java API and highlighting.

I recently found this page, maybe it helps you with another way of doing things?