Highlighting - limit number of highlights across fields

Is there a way to limit the total number of highlights returned across all
fields?

I know that you can set number_of_fragments in the top level settings but
this is the same as setting it for each field (instead of limiting the
total).

Example Query:
{
"query": {
"multi_match": {
"query": "event",
"fields": ["note", "subject"]
}
},
"highlight": {
"fragment_size": 50,
"number_of_fragments": 1,
"fields": {
"subject": {},
"body": {}
}
}
}

Example results:

{
...
"hits": [
{
"_index": "test",
"_type": "emails",
"_id": "181",
"_score": 6.82249,
"_source": {
"subject": "Upcoming event on the 25th July",
"body": "We need to prepare for the upcoming event that is going to
take place on the 25th July."
...
},
"highlight": {
"subject": [
"Upcoming event on the 25th July"
],
"body": [
"We need to prepare for the upcoming event that is..."
]
}
}
]
}

What I'm after:

{
...
"hits": [
{
"_index": "test",
"_type": "emails",
"_id": "181",
"_score": 6.82249,
"_source": {
"subject": "Upcoming event on the 25th July",
"body": "We need to prepare for the upcoming event that is going to
take place on the 25th July."
...
},
"highlight": {
"body": [
"We need to prepare for the upcoming event that is..."
]
}
}
]
}
(note only 1 highlight is returned)

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/43c1ffaa-fa7e-4104-ab29-4d057d162e77%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No, there isn't a way to do that. Just throwing away the extra results is
generally not a big deal unless the field is very expensive to highlight.
I've found highlighting to be reasonably cheap most of the time.

On Wed, Feb 5, 2014 at 11:38 AM, Michael Stringer <
michael.stringer@zestia.com> wrote:

Is there a way to limit the total number of highlights returned across all
fields?

I know that you can set number_of_fragments in the top level settings but
this is the same as setting it for each field (instead of limiting the
total).

Example Query:
{
"query": {
"multi_match": {
"query": "event",
"fields": ["note", "subject"]
}
},
"highlight": {
"fragment_size": 50,
"number_of_fragments": 1,
"fields": {
"subject": {},
"body": {}
}
}
}

Example results:

{
...
"hits": [
{
"_index": "test",
"_type": "emails",
"_id": "181",
"_score": 6.82249,
"_source": {
"subject": "Upcoming event on the 25th July",
"body": "We need to prepare for the upcoming event that is going
to take place on the 25th July."
...
},
"highlight": {
"subject": [
"Upcoming event on the 25th July"
],
"body": [
"We need to prepare for the upcoming event that is..."
]
}
}
]
}

What I'm after:

{
...
"hits": [
{
"_index": "test",
"_type": "emails",
"_id": "181",
"_score": 6.82249,
"_source": {
"subject": "Upcoming event on the 25th July",
"body": "We need to prepare for the upcoming event that is going
to take place on the 25th July."
...
},
"highlight": {
"body": [
"We need to prepare for the upcoming event that is..."
]
}
}
]
}
(note only 1 highlight is returned)

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/43c1ffaa-fa7e-4104-ab29-4d057d162e77%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAPmjWd0YDUJphg9_Hhmfh00ctwEz7tOHT4H0Ksi7FRaJo1nKgw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.