Skip to content

Commit e39b65c

Browse files
committed
Clarify highlighting docs for semantic_text
1 parent 71957ca commit e39b65c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

docs/reference/elasticsearch/mapping-reference/semantic-text.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,29 @@ POST test-index/_search
267267
```
268268

269269
1. Specifies the maximum number of fragments to return.
270-
2. Sorts highlighted fragments by score when set to `score`. By default,
270+
2. Sorts returned most relevant highlighted fragments by score when set to `score`. By default,
271271
fragments will be output in the order they appear in the field (order: none).
272272

273+
To use the `semantic` highlighter to view indexed chunks in the order which they
274+
were indexed and no scoring,
275+
use the `match_all` query to retrieve each chunk in the order which it appears
276+
in the document:
277+
278+
```console
279+
POST test-index/_search
280+
{
281+
"query": {
282+
"match_all": {}
283+
},
284+
"highlight": {
285+
"fields": {
286+
"my_semantic_field": {
287+
"number_of_fragments": 5
288+
}
289+
}
290+
}
291+
}
292+
273293
Highlighting is supported on fields other than semantic_text. However, if you
274294
want to restrict highlighting to the semantic highlighter and return no
275295
fragments when the field is not of type semantic_text, you can explicitly

docs/reference/elasticsearch/rest-apis/highlighting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ applies_to:
77

88
# Highlighting [highlighting]
99

10-
Highlighters enable you to get highlighted snippets from one or more fields in your search results so you can show users where the query matches are. When you request highlights, the response contains an additional `highlight` element for each search hit that includes the highlighted fields and the highlighted fragments.
10+
Highlighters enable you to retrieve the best-matching highlighted snippets from one or more fields in your search results so you can show users where the query matches are. When you request highlights, the response contains an additional `highlight` element for each search hit that includes the highlighted fields and the highlighted fragments.
1111

1212
::::{note}
1313
Highlighters don’t reflect the boolean logic of a query when extracting terms to highlight. Thus, for some complex boolean queries (e.g nested boolean queries, queries using `minimum_should_match` etc.), parts of documents may be highlighted that don’t correspond to query matches.

0 commit comments

Comments
 (0)