Skip to content

Commit

Permalink
Speed up search inside multi-field aggregation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kishorenc committed Nov 20, 2021
1 parent 1eb7c4e commit 60ca88e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2266,18 +2266,14 @@ void Index::search(std::vector<query_tokens_t>& field_query_tokens,

for(size_t token_index=0; token_index < field_query_tokens[i].q_include_tokens.size(); token_index++) {
const auto& token = field_query_tokens[i].q_include_tokens[token_index];
const art_leaf* leaf = (art_leaf *) art_search(search_index.at(field), (const unsigned char*) token.c_str(),
token.length()+1);

std::vector<art_leaf*> leaves;
const bool prefix_search = field_prefix && (token_index == field_query_tokens[i].q_include_tokens.size()-1);
const size_t token_len = prefix_search ? (int) token.length() : (int) token.length() + 1;
art_fuzzy_search(search_index.at(field), (const unsigned char *) token.c_str(), token_len,
0, 0, 1, token_order, prefix_search, nullptr, 0, leaves);

if(leaves.empty()) {
if(!leaf) {
continue;
}

if(!posting_t::contains(leaves[0]->values, seq_id)) {
if(!posting_t::contains(leaf->values, seq_id)) {
continue;
}

Expand Down

0 comments on commit 60ca88e

Please sign in to comment.