-
Notifications
You must be signed in to change notification settings - Fork 124
Description
What is the bug?
When calling opensearchapi.Client.Search
with a query with a highlight specified, the highlight results coming back in the raw json coming back from the OpenSearch cluster are not returned on the SearchHit
s in the SearchResp
.
How can one reproduce the bug?
Call opensearchapi.Client.Search() with a SearchReq
with a body with a highlight
property specifying highlights for fields that match in they query.
What is the expected behavior?
The SearchResp coming back from Client.Search
should include the highlight results in the SearchHits, as they are returned in the raw json api response from the OpenSearch cluster.
What is your host/environment?
using [email protected]
on mac os 14.7.2 and running in aws lambda.
querying Amazon OpenSearch Service 2.15 cluster.
Do you have any screenshots?
Do you have any additional context?
It seems like the highlight
field is already coming back in the raw json, and just needs to be added to SearchHit so that it will be populated when the json response is unmarshalled, like this:
type SearchHit struct {
Index string `json:"_index"`
ID string `json:"_id"`
Routing string `json:"_routing"`
Score float32 `json:"_score"`
Source json.RawMessage `json:"_source"`
Fields json.RawMessage `json:"fields"`
Type string `json:"_type"` // Deprecated field
Sort []any `json:"sort"`
Explanation *DocumentExplainDetails `json:"_explanation"`
SeqNo *int `json:"_seq_no"`
PrimaryTerm *int `json:"_primary_term"`
+ Highlight map[string][]string `json:"highlight"`
}
I'm happy to investigate this further and PR it, if it's not already in the works to add this field to the response.