Search: pass the 'explain' flag from the UI and debug paging issues (#51847)

This commit is contained in:
Ryan McKinley
2022-07-08 15:28:21 -04:00
committed by GitHub
parent 25edee88a7
commit eb6d6d0d2b
9 changed files with 135 additions and 19 deletions
+7 -2
View File
@@ -429,7 +429,8 @@ func doSearchQuery(
hasConstraints = true
}
if q.Query == "*" || q.Query == "" {
isMatchAllQuery := q.Query == "*" || q.Query == ""
if isMatchAllQuery {
if !hasConstraints {
fullQuery.AddShould(bluge.NewMatchAllQuery())
}
@@ -600,7 +601,11 @@ func doSearchQuery(
}
if q.Explain {
fScore.Append(match.Score)
if isMatchAllQuery {
fScore.Append(float64(fieldLen + q.From))
} else {
fScore.Append(match.Score)
}
if match.Explanation != nil {
js, _ := json.Marshal(&match.Explanation)
jsb := json.RawMessage(js)