Skip to content

Commit

Permalink
Allowing less than K nodes in result (Filter and Non Filter In Memory…
Browse files Browse the repository at this point in the history
… Search)
  • Loading branch information
NeelamMahapatro committed Dec 18, 2023
1 parent 0640c3f commit 77b432f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2251,14 +2251,13 @@ std::pair<uint32_t, uint32_t> Index<T, TagT, LabelT>::search(const T *query, con
break;
}

if (pos < K)
if (pos <= K)
{
context.SetState(State::Failure);
diskann::cerr << "Found pos: " << pos << "fewer than K elements " << K << " for query" << std::endl;
context.SetState(State::Success);
}
else
{
context.SetState(State::Success);
context.SetState(State::Failure);
}

return retval;
Expand Down Expand Up @@ -2387,14 +2386,13 @@ std::pair<uint32_t, uint32_t> Index<T, TagT, LabelT>::search_with_filters(const
if (pos == K)
break;
}
if (pos < K)
if (pos <= K)
{
context.SetState(State::Failure);
diskann::cerr << "Found fewer than K elements for query" << std::endl;
context.SetState(State::Success);
}
else
{
context.SetState(State::Success);
context.SetState(State::Failure);
}

return retval;
Expand Down

0 comments on commit 77b432f

Please sign in to comment.