-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search worker unification - removing duplicated ones #141
Conversation
a5992af
to
f7ff7ad
Compare
006a631
to
1dae47e
Compare
@@ -232,28 +232,40 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin | |||
} | |||
oldHandlingUsed = true | |||
fullQuery, columns := q.makeBasicQuery(ctx, queryTranslator, table, simpleQuery, queryInfo, highlighter) | |||
var columnsSlice [][]string | |||
if optAsync != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch and the one that starts in line 258
will be combined next time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, got minor comments.
quesma/quesma/search.go
Outdated
optAsync.doneCh <- AsyncSearchWithError{translatedQueryBody: translatedQueryBody, err: err} | ||
return | ||
} | ||
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody, err: nil} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would omit empty nil struct fields as we do above.
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody, err: nil} | |
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody} |
quesma/quesma/search.go
Outdated
q.searchAggregationWorker(ctx, aggregations, columns, queryTranslator, table, optAsync) | ||
translatedQueryBody, aggregationResults = q.searchWorker(ctx, aggregations, columns, table, true, optAsync) | ||
searchResponse := queryTranslator.MakeResponseAggregation(aggregations, aggregationResults) | ||
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody, err: nil} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above:
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody, err: nil} | |
optAsync.doneCh <- AsyncSearchWithError{response: searchResponse, translatedQueryBody: translatedQueryBody} |
} | ||
rows, err := q.logManager.ProcessQuery(dbQueryCtx, table, &agg, nil) | ||
rows, err := q.logManager.ProcessQuery(dbQueryCtx, table, &query, columns[columnsIndex]) | ||
if err != nil { | ||
logger.ErrorWithCtx(ctx).Msg(err.Error()) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why here we are not incrementing columnsIndex
. Looks like a bug.
quesma/quesma/search.go
Outdated
if agg.NoDBQuery { | ||
logger.InfoWithCtx(ctx).Msgf("pipeline query: %+v", agg) | ||
columnsIndex := 0 | ||
for _, query := range queries { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this fixes a bug and also you can simplify code:
for _, query := range queries { | |
for columnsIndex, query := range queries { |
hits = append(hits, postprocessedRows) | ||
} else { | ||
hits = append(hits, rows) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woulnd't it be simpler if we:
if doPostProcessing {
rows = query.Type.PostprocessResults(rows)
}
hits = append(hits, rows)
This PR combines
searchAggregationWorker
withsearchWorker
andsearchAggregationWorkerCommon
withsearchWorkerCommon