resolve_entity
Ask Brain which entity a surface form means — the four outcomes, and why Ambiguous writes nothing.
async fn resolve_entity(&self, input: &ResolveEntityInput) -> Result<ResolveEntityResult, BrainHttpError>async fn resolve_entity(&self, request: &EntityResolveRequest) -> Result<EntityResolveResponse>Parameters
candidate_namestringrequiredThe surface form to resolve — "Priya", "P. Raman".
resolution_contextstringoptionalSurrounding text to disambiguate with. This is what separates two people called Priya.
type_hintintegeroptionalRestrict candidates to one entity type. On the wire the field is entityTypeHint.
allow_createbooleanoptionalCreate the entity when nothing matches, instead of answering NotFound.
Returns
outcomeResolved | Created | Ambiguous | NotFoundalwaysResolved — matched an existing entity. Created — creation was allowed and nothing matched. Ambiguous — several candidates tied. NotFound — nothing matched and creation was not allowed.
tierintegeralwaysWhich resolution tier produced the answer — exact alias, normalised form, embedding similarity, and so on. Low tiers are cheap and certain.
confidencefloatalwaysConfidence in [0, 1].
entity_idstring | nullalwaysThe resolved entity — null on Ambiguous. On the wire the field is resolvedEntity.
candidate_idsstring[]alwaysThe tied candidates, populated on Ambiguous.
Example
let r = brain
.resolve_entity(&ResolveEntityInput {
candidate_name: "Priya".into(),
resolution_context: Some("the engineer who moved to Lisbon".into()),
allow_create: Some(false),
..Default::default()
})
.await?;
if r.outcome == "Ambiguous" {
// resolve by hand from r.candidate_ids
}When resolution is ambiguous Brain does not pick, and it does not link. The
statement that triggered the resolution is stored with no entity attached,
and nothing is logged as an error. Reading candidateIds and deciding is
the caller's job; ignoring the outcome is how a graph quietly loses its
edges.
The wire response also carries an auditId for the resolution, which the
HTTP result omits.
On the wire
Ids are fixed-width UUID bytes rather than strings, attributes is an opaque
attributesBlob, and every request carries a requestId plus an optional
actAs. See Wire client.
Was this page helpful?