Skip to content

Commit

Permalink
Simplify post processing (#179)
Browse files Browse the repository at this point in the history
Another simplification.
  • Loading branch information
jakozaur authored May 21, 2024
1 parent 6d7a425 commit f40428c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions quesma/quesma/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin
defer recovery.LogAndHandlePanic(ctx, func() {
doneCh <- AsyncSearchWithError{err: errors.New("panic")}
})
translatedQueryBody, hitsSlice := q.searchWorker(ctx, queries, append(columnsSlice, columns), table, false, doneCh, optAsync)
translatedQueryBody, hitsSlice := q.searchWorker(ctx, queries, append(columnsSlice, columns), table, doneCh, optAsync)
searchResponse, err := queryTranslator.MakeSearchResponse(hitsSlice[0], queries[0])
if err != nil {
logger.ErrorWithCtx(ctx).Msgf("error making response: %v, queryInfo: %+v, rows: %v", err, queries[0].QueryInfo, hits)
Expand All @@ -281,7 +281,7 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin
defer recovery.LogAndHandlePanic(ctx, func() {
doneCh <- AsyncSearchWithError{err: errors.New("panic")}
})
translatedQueryBody, aggregationResults = q.searchWorker(ctx, queries, columns, table, true, doneCh, optAsync)
translatedQueryBody, aggregationResults = q.searchWorker(ctx, queries, columns, table, doneCh, optAsync)
searchResponse := queryTranslator.MakeResponseAggregation(queries, aggregationResults)
doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody}
}()
Expand Down Expand Up @@ -473,8 +473,7 @@ func (q *QueryRunner) searchWorkerCommon(
ctx context.Context,
queries []model.Query,
columns [][]string,
table *clickhouse.Table,
doPostProcessing bool) (translatedQueryBody []byte, hits [][]model.QueryResultRow) {
table *clickhouse.Table) (translatedQueryBody []byte, hits [][]model.QueryResultRow) {
sqls := ""
for columnsIndex, query := range queries {
if query.NoDBQuery {
Expand All @@ -488,7 +487,7 @@ func (q *QueryRunner) searchWorkerCommon(
logger.ErrorWithCtx(ctx).Msg(err.Error())
continue
}
if doPostProcessing && query.Type != nil {
if query.Type != nil {
rows = query.Type.PostprocessResults(rows)
}
hits = append(hits, rows)
Expand All @@ -501,7 +500,6 @@ func (q *QueryRunner) searchWorker(ctx context.Context,
aggregations []model.Query,
columns [][]string,
table *clickhouse.Table,
doPostProcessing bool,
doneCh chan<- AsyncSearchWithError,
optAsync *AsyncQuery) (translatedQueryBody []byte, resultRows [][]model.QueryResultRow) {
if optAsync != nil {
Expand All @@ -513,7 +511,7 @@ func (q *QueryRunner) searchWorker(ctx context.Context,
ctx = dbQueryCtx
}

return q.searchWorkerCommon(ctx, aggregations, columns, table, doPostProcessing)
return q.searchWorkerCommon(ctx, aggregations, columns, table)
}

func (q *QueryRunner) Close() {
Expand Down

0 comments on commit f40428c

Please sign in to comment.