INNER CODE UNIT · Rust
length_range
apollographql/apollo-mcp-server · crates/apollo-schema-index/src/lib.rs:523
let length_range = (max_length - min_length) as f32;
// Apply normalized boost to each path
scored_paths
.into_iter()
.map(|scored_path| {
let path_length = scored_path.inner.len();
let normalized_length = (path_length - min_length) as f32 / length_range;
// Boost shorter paths: 1.0 for shortest, 0.0 for longest
let length_boost = 1.0 - normalized_length;
let boosted_score = scored_path.score() * (1.0 + boost_factor * length_boost);
Scored::new(scored_path.inner, boosted_score)
})
.collect()
}
/// Create the query used to search for a given set of terms.
fn query<I>(&self, terms: I) -> impl Query