pub fn build_vector_selector(schema: &Schema) -> VectorSelectorSpecExpand description
Build an optimal vector selector based on the projected schema.
This function analyzes the DataFusion schema (after projection) to determine
which vector fields are actually needed, enabling efficient queries that only
fetch required data from Qdrant.
§Arguments
schema- The Arrow schema (potentially projected) defining which fields are needed
§Returns
A VectorSelectorSpec that tells Qdrant exactly which vectors to include in the response.
§Examples
ⓘ
use datafusion::arrow::datatypes::{Schema, Field, DataType};
use qdrant_datafusion::utils::{build_vector_selector, VectorSelectorSpec};
use std::sync::Arc;
// Schema with only metadata - no vectors needed
let metadata_schema = Schema::new(vec![
Field::new("id", DataType::Utf8, false),
Field::new("payload", DataType::Utf8, true),
]);
assert!(matches!(build_vector_selector(&metadata_schema), VectorSelectorSpec::None));
// Schema with unnamed vector - fetch all
let unnamed_schema = Schema::new(vec![
Field::new("id", DataType::Utf8, false),
Field::new("vector", DataType::List(Arc::new(Field::new("item", DataType::Float32, true))), true),
]);
assert!(matches!(build_vector_selector(&unnamed_schema), VectorSelectorSpec::All));