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

Since:
  • 4.3.0
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

snippet(startTag, endTag, maxFragmentLength, maxFragments, fragmentSeparator, maxDocCharsToAnalyze) : String

Returns a snippet of the content which contains the matching term(s)

Name Type Description
startTag string

Text which should be inserted before matching terms in the snippet.

endTag string

Text which should be inserted before matching terms in the snippet

maxFragmentLength number

Maximum length of a text fragment in the snippet excluding start and end tags

maxFragments number

Maximum number of text fragements in a snippet

fragmentSeparator string

Separator

maxDocCharsToAnalyze string

Maximum text length for snippet search

Since:
  • 4.4.0
Returns:
Type Description
String