Skip to content

Commit

Permalink
Be more concise
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski committed May 17, 2024
1 parent 27ae3f0 commit 006a631
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions quesma/quesma/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,13 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin
}
oldHandlingUsed = true
fullQuery, columns := q.makeBasicQuery(ctx, queryTranslator, table, simpleQuery, queryInfo, highlighter)
queries := []model.Query{*fullQuery}
columnsSlice := make([][]string, len(queries))
columnsSlice[0] = columns
var columnsSlice [][]string
if optAsync != nil {
go func() {
defer recovery.LogAndHandlePanic(ctx, func() {
optAsync.doneCh <- AsyncSearchWithError{err: errors.New("panic")}
})
translatedQueryBody, hitsSlice := q.searchWorker(ctx, queries, columnsSlice, table, false, optAsync)
translatedQueryBody, hitsSlice := q.searchWorker(ctx, []model.Query{*fullQuery}, append(columnsSlice, columns), table, false, optAsync)
searchResponse, err := queryTranslator.MakeSearchResponse(hitsSlice[0], fullQuery.QueryInfo.Typ, fullQuery.Highlighter)
if err != nil {
logger.ErrorWithCtx(ctx).Msgf("error making response: %v, queryInfo: %+v, rows: %v", err, fullQuery.QueryInfo, hits)
Expand All @@ -251,7 +249,7 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin
}()
} else {
var hitsSlice [][]model.QueryResultRow
translatedQueryBody, hitsSlice = q.searchWorker(ctx, queries, columnsSlice, table, false, nil)
translatedQueryBody, hitsSlice = q.searchWorker(ctx, []model.Query{*fullQuery}, append(columnsSlice, columns), table, false, nil)
hits = hitsSlice[0]
}
} else if aggregations, err = queryTranslator.ParseAggregationJson(string(body)); err == nil {
Expand Down

0 comments on commit 006a631

Please sign in to comment.