[ActiveContext] Refactor Query

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Context

ActiveContext::Query.knn

When calling ::ActiveContext::Query.filter(...).knn, the knn method requires a limit parameter. This refers to the k nearest neighbors in knn, but this could be misunderstood as a search results limit. In order to prevent confusion, we should rename this parameter to k.

Proposal

  1. Rename knn limit argument to k
  2. Update documentation for ^
  3. Add an instance method for filter query so that it can be called as this example
  4. Add documentation for ^

Example of using filter instance method.

base_query = ::ActiveContext::Query.knn(
  target: current_embeddings_field,
  vector: target_embeddings,
  limit: KNN_COUNT
)

project_ids.each do |project_id|
  query = base_query.filter(
    project_id: project_id
  )
end
Edited by 🤖 GitLab Bot 🤖