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. |
Methods
static$k.Hit.unwrap(hits) : Array.<$k.SemanticElement>
Map each hit to a semantic element. Equivalent to (but much faster than)
hits.map(function(h) { return h.element())
Name | Type | Description |
---|---|---|
hits |
Array.<$k.Hit> |
Hits. Elements are accepted, too (returns the element itself). |
- Since:
- 5.3.1
Returns:
Type | Description |
---|---|
Array.<$k.SemanticElement> |
static$k.Hit.wrap(elements, quality) : Array.<$k.Hit>
Map each element to a hit. Equivalent to (but much faster than)
elements.map(function(e) { return new $k.Hit(e, q) })
Name | Type | Description |
---|---|---|
elements |
Array.<$k.SemanticElement> |
Element. Hits are accepted, too (returns the hit itself). |
quality |
number |
optional
Quality of each hit |
- Since:
- 5.3.1
Returns:
Type | Description |
---|---|
Array.<$k.Hit> |
attributeType() : $k.AttributeType
Returns the attribute type of the hit
- Since:
- 5.2.2
Returns:
Type | Description |
---|---|
$k.AttributeType |
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> |
causePropertyElements(propertyKeys) : Array.<$k.SemanticElement>
Returns the elements of all properties matching the given property-keys of all (custom-) causes of this hit
Name | Type | Description |
---|---|---|
propertyKeys |
Array.<string> |
optional
property keys |
- Since:
- 5.3.0
Returns:
Type | Description |
---|---|
Array.<$k.SemanticElement> |
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 |
language() : string
Returns the language of the hit for translated attributes,
or undefined if not translated
- Since:
- 5.2.2
Returns:
Type | Description |
---|---|
string |
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 |