Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions docs/changelog/129509.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 129509
summary: Fix NPE in `SemanticTextHighlighter`
area: Search
type: bug
issues:
- 129501
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public HighlightField highlight(FieldHighlightContext fieldContext) throws IOExc
return null;
}
SemanticTextFieldType fieldType = (SemanticTextFieldType) fieldContext.fieldType;
if (fieldType.getEmbeddingsField() == null) {
if (fieldType.getModelSettings() == null || fieldType.getEmbeddingsField() == null) {
// nothing indexed yet
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ setup:
body:
type: semantic_text
inference_id: dense-inference-id
another_body:
type: semantic_text
inference_id: dense-inference-id

- do:
index:
Expand All @@ -79,6 +82,22 @@ setup:
body: [ "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides.", "You Know, for Search!" ]
refresh: true

---
"Highlighting empty field":
- do:
search:
index: test-dense-index
body:
query:
match_all: {}
highlight:
fields:
another_body: {}

- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "doc_1" }
- not_exists: hits.hits.0.highlight.another_body

---
"Highlighting using a sparse embedding model":
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,35 @@ setup:
body:
type: semantic_text
inference_id: dense-inference-id
another_body:
type: semantic_text
inference_id: dense-inference-id

---
"Highlighting empty field":
- do:
index:
index: test-dense-index
id: doc_1
body:
body: [ "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides.", "You Know, for Search!" ]
refresh: true

- match: { result: created }

- do:
search:
index: test-dense-index
body:
query:
match_all: {}
highlight:
fields:
another_body: {}

- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "doc_1" }
- not_exists: hits.hits.0.highlight.another_body

---
"Highlighting using a sparse embedding model":
Expand Down