Skip to main content

detect_score

Function detect_score 

Source
pub fn detect_score(items: &[Value]) -> Result<ScoreDetection, FaceError>
Expand description

§4.3: scan the items for a numeric score field.

Returns Ok(ScoreDetection) even when no score is found — “no score detected” is a normal outcome and not an error. The caller decides whether absence of a score is fatal in its context.

--score=PATH from the CLI bypasses detection entirely and is validated by validate_score_path; see that function’s docs.

§Errors

This function does not currently return any FaceError variant; the Result shape is reserved for future structural validation (e.g. surfacing a parse failure on the items list itself).

§Examples

use face_core::detect::detect_score;
use serde_json::json;

let items = vec![json!({"score": 0.91, "doc": "a"})];
let det = detect_score(&items).unwrap();
assert_eq!(det.path.as_deref(), Some(".score"));