new 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 |
If the quality is not between 0 and 1
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
(static) 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
- Type:
- Array.<$k.SemanticElement>
(static) wrap(elements, qualityopt) → {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 | Attributes | 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
- Type:
- Array.<$k.Hit>
addCause(cause)
Add a cause
Name | Type | Description |
---|---|---|
cause | $k.Cause |
attributeType() → {$k.AttributeType}
Returns the attribute type of the hit
- Since
- 5.2.2
- Type:
- $k.AttributeType
causeOfType(type) → {$k.Cause}
Returns the cause of this hit with the given type, or undefined if no or more than one cause exists
Name | Type | Description |
---|---|---|
type | string | The type of cause |
- Type:
- $k.Cause
causePropertyElements(propertyKeysopt) → {Array.<$k.SemanticElement>}
Returns the elements of all properties matching the given property-keys of all (custom-) causes of this hit
Name | Type | Attributes | Description |
---|---|---|---|
propertyKeys | Array.<string> | <optional> | property keys |
- Since
- 5.3.0
- Type:
- Array.<$k.SemanticElement>
causes() → {Array.<$k.Cause>}
Returns the causes of this hit
- Type:
- Array.<$k.Cause>
causesOfType(type) → {Array.<$k.Cause>}
Returns the causes of this hit with the given type
Name | Type | Description |
---|---|---|
type | string | The type of cause |
- Type:
- Array.<$k.Cause>
element() → {$k.SemanticElement}
The semantic element associated with this hit
- Since
- 4.3.0
- Type:
- $k.SemanticElement
language() → {string}
Returns the language of the hit for translated attributes, or undefined if not translated
- Since
- 5.2.2
- Type:
- string
quality() → {number}
Returns the quality of the hit, a number between 0 (worst quality) and 1 (best quality)
- Type:
- number
setElement(semanticElement)
Set the semantic element associated with this hit
Name | Type | Description |
---|---|---|
semanticElement | $k.SemanticElement | Semantic element of the hit |
If the argument is not a semantic element
setQuality(quality)
Set the quality, a number between 0 and 1
Name | Type | Description |
---|---|---|
quality | number |
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
- Type:
- String