Skip to content

Commit

Permalink
refactor(search_family): address comments 4
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Bagritsevich <[email protected]>
  • Loading branch information
BagritsevichStepan committed Nov 20, 2024
1 parent 8375d3f commit f384ec6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/server/search/doc_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ std::pair<SearchFieldsList, SortIndiciesFieldsList> PreprocessAggregateFields(
sort_fields.emplace_back(fident, fname);
}

return {fields, sort_fields};
return {std::move(fields), std::move(sort_fields)};
}

vector<SearchDocData> ShardDocIndex::SearchForAggregator(
Expand Down
9 changes: 5 additions & 4 deletions src/server/search/search_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void ParseLoadFields(CmdArgParser* parser, std::optional<SearchFieldsList>* load
StringOrView name = StringOrView::FromString(std::string{str});
if (parser->Check("AS")) {
load_fields->value().emplace_back(name, true,
StringOrView::FromString(std::string{parser->Next()}));
StringOrView::FromString(parser->Next<std::string>()));
} else {
load_fields->value().emplace_back(name, true);
}
Expand Down Expand Up @@ -268,11 +268,11 @@ optional<SearchParams> ParseSearchParamsOrReply(CmdArgParser* parser, SinkReplyB
size_t num_fields = parser->Next<size_t>();
params.return_fields.emplace();
while (params.return_fields->size() < num_fields) {
StringOrView name = StringOrView::FromString(std::string{parser->Next()});
StringOrView name = StringOrView::FromString(parser->Next<std::string>());

if (parser->Check("AS")) {
params.return_fields->emplace_back(std::move(name), true,
StringOrView::FromString(std::string{parser->Next()}));
StringOrView::FromString(parser->Next<std::string>()));
} else {
params.return_fields->emplace_back(std::move(name), true);
}
Expand All @@ -283,7 +283,8 @@ optional<SearchParams> ParseSearchParamsOrReply(CmdArgParser* parser, SinkReplyB
} else if (parser->Check("PARAMS")) { // [PARAMS num(ignored) name(ignored) knn_vector]
params.query_params = ParseQueryParams(parser);
} else if (parser->Check("SORTBY")) {
params.sort_option = search::SortOption{string{parser->Next()}, bool(parser->Check("DESC"))};
params.sort_option =
search::SortOption{parser->Next<std::string>(), bool(parser->Check("DESC"))};
} else {
// Unsupported parameters are ignored for now
parser->Skip(1);
Expand Down

0 comments on commit f384ec6

Please sign in to comment.