Class: Hit

$k. Hit

new $k.Hit(semanticElement, quality)

Creates a new hit

Name Type Description
semanticElement $k.SemanticElement

Semantic element of the hit

quality number

Quality of the hit. If undefined, 1 will be set as quality

Throws:
Type Description
$k.exception.InvalidValue

If the quality is not between 0 and 1

$k.exception.TypeError

If the argument is not a semantic element

Provides details about a topic returned by a query.
Each hit has a quality between 0 (worst quality) and 1 (best quality).
Additional details are attached as causes.

Methods

addCause(cause)

Add a cause

Name Type Description
cause $k.Cause

causeOfType() : Array.<$k.Cause>

Returns the cause of this hit with the given type, or undefined if no or more than one cause exists

Returns:
Type Description
Array.<$k.Cause>

causes() : Array.<$k.Cause>

Returns the causes of this hit

Returns:
Type Description
Array.<$k.Cause>

causesOfType() : Array.<$k.Cause>

Returns the causes of this hit with the given type

Returns:
Type Description
Array.<$k.Cause>

element() : $k.SemanticElement

The semantic element associated with this hit

Returns:
Type Description
$k.SemanticElement

quality() : number

Returns the quality of the hit, a number between 0 (worst quality) and 1 (best quality)

Returns:
Type Description
number

setElement(semanticElement)

Set the semantic element associated with this hit

Name Type Description
semanticElement $k.SemanticElement

Semantic element of the hit

Throws:
Type Description
$k.exception.TypeError

If the argument is not a semantic element

setQuality(quality)

Set the quality, a number between 0 and 1

Name Type Description
quality number
Throws:
Type Description
$k.exception.InvalidValue

If the quality is not between 0 and 1