@@ -332,15 +332,28 @@ auto build(raft::resources const& handle,
332332 * Note, this function requires a temporary buffer to store intermediate results between cuda kernel
333333 * calls, which may lead to undesirable allocations and slowdown. To alleviate the problem, you can
334334 * pass a pool memory resource or a large enough pre-allocated memory resource to reduce or
335- * eliminate entirely allocations happening within `search`:
335+ * eliminate entirely allocations happening within `search`.
336+ *
337+ * Usage example:
336338 * @code{.cpp}
337- * ...
338- * // Use the same allocator across multiple searches to reduce the number of
339- * // cuda memory allocations
340- * brute_force::search(handle, index, queries1, out_inds1, out_dists1);
341- * brute_force::search(handle, index, queries2, out_inds2, out_dists2);
342- * brute_force::search(handle, index, queries3, out_inds3, out_dists3);
343- * ...
339+ * using namespace cuvs::neighbors;
340+ *
341+ * // use default index parameters
342+ * brute_force::index_params index_params;
343+ * // create and fill the index from a [N, D] dataset
344+ * brute_force::index_params index_params;
345+ * auto index = brute_force::build(handle, index_params, dataset);
346+ * // use default search parameters
347+ * brute_force::search_params search_params;
348+ * // create a bitset to filter the search
349+ * auto removed_indices = raft::make_device_vector<int64_t, int64_t>(res, n_removed_indices);
350+ * raft::core::bitset<std::uint32_t, int64_t> removed_indices_bitset(
351+ * res, removed_indices.view(), dataset.extent(0));
352+ * // search K nearest neighbours according to a bitset
353+ * auto neighbors = raft::make_device_matrix<uint32_t>(res, n_queries, k);
354+ * auto distances = raft::make_device_matrix<float>(res, n_queries, k);
355+ * auto filter = filtering::bitset_filter(removed_indices_bitset.view());
356+ * brute_force::search(res, search_params, index, queries, neighbors, distances, filter);
344357 * @endcode
345358 *
346359 * @param[in] handle
@@ -350,9 +363,17 @@ auto build(raft::resources const& handle,
350363 * @param[out] neighbors a device pointer to the indices of the neighbors in the source dataset
351364 * [n_queries, k]
352365 * @param[out] distances a device pointer to the distances to the selected neighbors [n_queries, k]
353- * @param[in] sample_filter An optional device bitmap filter function with a `row-major` layout and
354- * the shape of [n_queries, index->size()], which means the filter will use the first
355- * `index->size()` bits to indicate whether queries[0] should compute the distance with dataset.
366+ * @param[in] sample_filter An optional device filter that restricts which dataset elements should
367+ * be considered for each query.
368+ *
369+ * - Supports two types of filters:
370+ * 1. **Bitset Filter**: A shared filter where each bit corresponds to a dataset element.
371+ * All queries share the same filter, with a logical shape of `[1, index->size()]`.
372+ * 2. **Bitmap Filter**: A per-query filter with a logical shape of `[n_queries, index->size()]`,
373+ * where each bit indicates whether a specific dataset element should be considered for a
374+ * particular query. (1 for inclusion, 0 for exclusion).
375+ *
376+ * - The default value is `none_sample_filter`, which applies no filtering.
356377 */
357378void search (raft::resources const & handle,
358379 const cuvs::neighbors::brute_force::search_params& params,
@@ -379,15 +400,28 @@ void search(raft::resources const& handle,
379400 * Note, this function requires a temporary buffer to store intermediate results between cuda kernel
380401 * calls, which may lead to undesirable allocations and slowdown. To alleviate the problem, you can
381402 * pass a pool memory resource or a large enough pre-allocated memory resource to reduce or
382- * eliminate entirely allocations happening within `search`:
403+ * eliminate entirely allocations happening within `search`.
404+ *
405+ * Usage example:
383406 * @code{.cpp}
384- * ...
385- * // Use the same allocator across multiple searches to reduce the number of
386- * // cuda memory allocations
387- * brute_force::search(handle, index, queries1, out_inds1, out_dists1);
388- * brute_force::search(handle, index, queries2, out_inds2, out_dists2);
389- * brute_force::search(handle, index, queries3, out_inds3, out_dists3);
390- * ...
407+ * using namespace cuvs::neighbors;
408+ *
409+ * // use default index parameters
410+ * brute_force::index_params index_params;
411+ * // create and fill the index from a [N, D] dataset
412+ * brute_force::index_params index_params;
413+ * auto index = brute_force::build(handle, index_params, dataset);
414+ * // use default search parameters
415+ * brute_force::search_params search_params;
416+ * // create a bitset to filter the search
417+ * auto removed_indices = raft::make_device_vector<int64_t, int64_t>(res, n_removed_indices);
418+ * raft::core::bitset<std::uint32_t, int64_t> removed_indices_bitset(
419+ * res, removed_indices.view(), dataset.extent(0));
420+ * // search K nearest neighbours according to a bitset
421+ * auto neighbors = raft::make_device_matrix<uint32_t>(res, n_queries, k);
422+ * auto distances = raft::make_device_matrix<half>(res, n_queries, k);
423+ * auto filter = filtering::bitset_filter(removed_indices_bitset.view());
424+ * brute_force::search(res, search_params, index, queries, neighbors, distances, filter);
391425 * @endcode
392426 *
393427 * @param[in] handle
@@ -397,8 +431,17 @@ void search(raft::resources const& handle,
397431 * @param[out] neighbors a device pointer to the indices of the neighbors in the source dataset
398432 * [n_queries, k]
399433 * @param[out] distances a device pointer to the distances to the selected neighbors [n_queries, k]
400- * @param[in] sample_filter a optional device bitmap filter function that greenlights samples for a
401- * given
434+ * @param[in] sample_filter An optional device filter that restricts which dataset elements should
435+ * be considered for each query.
436+ *
437+ * - Supports two types of filters:
438+ * 1. **Bitset Filter**: A shared filter where each bit corresponds to a dataset element.
439+ * All queries share the same filter, with a logical shape of `[1, index->size()]`.
440+ * 2. **Bitmap Filter**: A per-query filter with a logical shape of `[n_queries, index->size()]`,
441+ * where each bit indicates whether a specific dataset element should be considered for a
442+ * particular query. (1 for inclusion, 0 for exclusion).
443+ *
444+ * - The default value is `none_sample_filter`, which applies no filtering.
402445 */
403446void search (raft::resources const & handle,
404447 const cuvs::neighbors::brute_force::search_params& params,
@@ -421,15 +464,51 @@ void search(raft::resources const& handle,
421464 *
422465 * See the [brute_force::build](#brute_force::build) documentation for a usage example.
423466 *
467+ * Note, this function requires a temporary buffer to store intermediate results between cuda kernel
468+ * calls, which may lead to undesirable allocations and slowdown. To alleviate the problem, you can
469+ * pass a pool memory resource or a large enough pre-allocated memory resource to reduce or
470+ * eliminate entirely allocations happening within `search`.
471+ *
472+ * Usage example:
473+ * @code{.cpp}
474+ * using namespace cuvs::neighbors;
475+ *
476+ * // use default index parameters
477+ * brute_force::index_params index_params;
478+ * // create and fill the index from a [N, D] dataset
479+ * brute_force::index_params index_params;
480+ * auto index = brute_force::build(handle, index_params, dataset);
481+ * // use default search parameters
482+ * brute_force::search_params search_params;
483+ * // create a bitset to filter the search
484+ * auto removed_indices = raft::make_device_vector<int64_t, int64_t>(res, n_removed_indices);
485+ * raft::core::bitset<std::uint32_t, int64_t> removed_indices_bitset(
486+ * res, removed_indices.view(), dataset.extent(0));
487+ * // search K nearest neighbours according to a bitset
488+ * auto neighbors = raft::make_device_matrix<uint32_t>(res, n_queries, k);
489+ * auto distances = raft::make_device_matrix<float>(res, n_queries, k);
490+ * auto filter = filtering::bitset_filter(removed_indices_bitset.view());
491+ * brute_force::search(res, search_params, index, queries, neighbors, distances, filter);
492+ * @endcode
493+ *
424494 * @param[in] handle
425495 * @param[in] params parameters configuring the search
426496 * @param[in] index bruteforce constructed index
427497 * @param[in] queries a device pointer to a col-major matrix [n_queries, index->dim()]
428498 * @param[out] neighbors a device pointer to the indices of the neighbors in the source dataset
429499 * [n_queries, k]
430500 * @param[out] distances a device pointer to the distances to the selected neighbors [n_queries, k]
431- * @param[in] sample_filter an optional device bitmap filter function that greenlights samples for a
432- * given query
501+ * @param[in] sample_filter An optional device filter that restricts which dataset elements should
502+ * be considered for each query.
503+ *
504+ * - Supports two types of filters:
505+ * 1. **Bitset Filter**: A shared filter where each bit corresponds to a dataset element.
506+ * All queries share the same filter, with a logical shape of `[1, index->size()]`.
507+ * 2. **Bitmap Filter**: A per-query filter with a logical shape of `[n_queries, index->size()]`,
508+ * where each bit indicates whether a specific dataset element should be considered for a
509+ * particular query. (1 for inclusion, 0 for exclusion).
510+ *
511+ * - The default value is `none_sample_filter`, which applies no filtering.
433512 */
434513void search (raft::resources const & handle,
435514 const cuvs::neighbors::brute_force::search_params& params,
@@ -452,15 +531,51 @@ void search(raft::resources const& handle,
452531 *
453532 * See the [brute_force::build](#brute_force::build) documentation for a usage example.
454533 *
534+ * Note, this function requires a temporary buffer to store intermediate results between cuda kernel
535+ * calls, which may lead to undesirable allocations and slowdown. To alleviate the problem, you can
536+ * pass a pool memory resource or a large enough pre-allocated memory resource to reduce or
537+ * eliminate entirely allocations happening within `search`.
538+ *
539+ * Usage example:
540+ * @code{.cpp}
541+ * using namespace cuvs::neighbors;
542+ *
543+ * // use default index parameters
544+ * brute_force::index_params index_params;
545+ * // create and fill the index from a [N, D] dataset
546+ * brute_force::index_params index_params;
547+ * auto index = brute_force::build(handle, index_params, dataset);
548+ * // use default search parameters
549+ * brute_force::search_params search_params;
550+ * // create a bitset to filter the search
551+ * auto removed_indices = raft::make_device_vector<int64_t, int64_t>(res, n_removed_indices);
552+ * raft::core::bitset<std::uint32_t, int64_t> removed_indices_bitset(
553+ * res, removed_indices.view(), dataset.extent(0));
554+ * // search K nearest neighbours according to a bitset
555+ * auto neighbors = raft::make_device_matrix<uint32_t>(res, n_queries, k);
556+ * auto distances = raft::make_device_matrix<half>(res, n_queries, k);
557+ * auto filter = filtering::bitset_filter(removed_indices_bitset.view());
558+ * brute_force::search(res, search_params, index, queries, neighbors, distances, filter);
559+ * @endcode
560+ *
455561 * @param[in] handle
456562 * @param[in] params parameters configuring the search
457563 * @param[in] index bruteforce constructed index
458564 * @param[in] queries a device pointer to a col-major matrix [n_queries, index->dim()]
459565 * @param[out] neighbors a device pointer to the indices of the neighbors in the source dataset
460566 * [n_queries, k]
461567 * @param[out] distances a device pointer to the distances to the selected neighbors [n_queries, k]
462- * @param[in] sample_filter an optional device bitmap filter function that greenlights samples for a
463- * given query
568+ * @param[in] sample_filter An optional device filter that restricts which dataset elements should
569+ * be considered for each query.
570+ *
571+ * - Supports two types of filters:
572+ * 1. **Bitset Filter**: A shared filter where each bit corresponds to a dataset element.
573+ * All queries share the same filter, with a logical shape of `[1, index->size()]`.
574+ * 2. **Bitmap Filter**: A per-query filter with a logical shape of `[n_queries, index->size()]`,
575+ * where each bit indicates whether a specific dataset element should be considered for a
576+ * particular query. (1 for inclusion, 0 for exclusion).
577+ *
578+ * - The default value is `none_sample_filter`, which applies no filtering.
464579 */
465580void search (raft::resources const & handle,
466581 const cuvs::neighbors::brute_force::search_params& params,
0 commit comments