Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion docs/reference/elasticsearch/mapping-reference/semantic-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,29 @@ POST test-index/_search
```

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

To use the `semantic` highlighter to view indexed chunks in the order which they
were indexed and no scoring,
use the `match_all` query to retrieve each chunk in the order which it appears
in the document:

```console
POST test-index/_search
{
"query": {
"match_all": {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Samiul-TheSoccerFan what version should this be tagged with?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was backported all the way to 8.18 and 9.0. If you are looking for specific versions, I would say from 8.18.4 and 9.0.4.

},
"highlight": {
"fields": {
"my_semantic_field": {
"number_of_fragments": 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call out adjusting number_of_fragments here to a larger number to get all chunks in a doc, and how that will be variable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 8cae0f6 LMKWYT

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

}
}
}
}

Highlighting is supported on fields other than semantic_text. However, if you
want to restrict highlighting to the semantic highlighter and return no
fragments when the field is not of type semantic_text, you can explicitly
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/elasticsearch/rest-apis/highlighting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ applies_to:

# Highlighting [highlighting]

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.
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice light-touch change 👍


::::{note}
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.
Expand Down
Loading