$k. StructuredQuery

new StructuredQuery(domainsopt)

Constructs structured query

Parameters:
NameTypeAttributesDescription
domains$k.Domain<optional>

The domain or internal name of a type

Since
  • 4.1.0 Represents a structured query

Extends

Methods

addAlternativeGroup() → {$k.AlternativeGroupCondition}

Add an empty alternative condition group (OR group)

Since
  • 4.2.0

addAttribute(type) → {$k.HasAttributeCondition}

Add an empty attribute condition without value/cardinality conditions

Parameters:
NameTypeDescription
type

AttributeType or internal name

Since
  • 4.1.0
Throws:

addAttributeValue(type, parameteropt, operatoropt, defaultValueopt) → {$k.AttributeValueCondition}

Add an attribute value condition

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

parameter<optional>

Parameter name of the value

operatorstring<optional>

Name of operator

defaultValue<optional>

Default value if no parameter is specified

Since
  • 4.1.0
Throws:

addCardinality(type, cardinality, operatoropt)

Add a cardinality condition

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

cardinalitynumber

Cardinality. Must be an integer >= 0.

operatorstring<optional>

Name of cardinality operator. One of

  • "==" or "equalCardinality" (cardinality must be equal to the value)
  • ">=" or "equalMinCardinality" (cardinality must be equal or greater than value)
  • "<=" or "equalMaxCardinality" (cardinality must be equal or less than value)
Default is "equalCardinality"

Since
  • 4.1.0
Throws:
Returns:

HasAttribute or HasRelation condition

addElementsFilter(parameter) → {$k.ElementsCondition}

Add an element condition. Only elements from the list / parameter are returned.

Parameters:
NameTypeDescription
parameter

Element or array of elements or the name of a parameter to use its value

Since
  • 4.1.0
Throws:
Returns:
Type: 
$k.ElementsCondition

addHandle(parameter) → {Condition}

Add a handle

Parameters:
NameTypeDescription
parameterstring
Version
  • Experimental feature, might be removed at any time
Since
  • 4.1.0
Returns:
Type: 
Condition

addQueryReference(queryopt, operatoropt) → {QueryReferenceCondition}

References another query that selects elements of this query according to the operator. If $k.Operator.EQUAL or NOT_EQUAL are selected, then the reference works in both directions. If $k.Operator.FILTER is selected, then the subquery is only applied to this query.

Parameters:
NameTypeAttributesDescription
query<optional>

Referenced query. A new empty query will be referenced if not defined

operatorstring<optional>

An operator that defines how the subquery is applied. One of $k.Operator.EQUAL, NOT_EQUAL, FILTER. Default is FILTER

Since
  • 4.1.0
Throws:

If the condition is not valid

Type
$k.exception.QueryError
Returns:

Condition for the subquery

Type: 
QueryReferenceCondition

addRelation(type) → {$k.HasRelationCondition}

Add an empty relation condition without target/cardinality conditions

Parameters:
NameTypeDescription
type

RelationType or internal name

Since
  • 4.1.0
Throws:

addRelationTarget(type, targetQueryopt) → {$k.RelationTargetCondition}

Add a relation target condition

Parameters:
NameTypeAttributesDescription
type

RelationType or internal name

targetQuery<optional>

Target query. If not specified an empty subquery will be build

Since
  • 4.1.0
Throws:
Returns:

Condition for the relation target

Type: 
$k.RelationTargetCondition

clone() → {$k.StructuredQuery}

Returns a copy of the query. The copy can be modified.

Since
  • 4.1.0
Throws:

If the query cannot be cloned

Type
$k.exception.QueryError
Returns:
Type: 
$k.StructuredQuery

conditions() → {Array.<QueryConditon>}

Returns the conditions of the query

Since
  • 4.1.0
Returns:
Type: 
Array.<QueryConditon>

definedParameters() → {Array.<$k.QueryParameter>}

Returns the parameters of the query

Returns:
Type: 
Array.<$k.QueryParameter>

domains() → {Array.<$k.Domain>}

Returns the domains of the query

Since
  • 4.1.0
Returns:
Type: 
Array.<$k.Domain>

explainElements(elements, parametersopt) → {Array.<$k.SemanticElement>}

Returns elements involved in the query

Parameters:
NameTypeAttributesDescription
elementsArray.<$k.SemanticElement>

Elements to explain. Elements that do not match the query are ignored.

parametersobject<optional>
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:
Type: 
Array.<$k.SemanticElement>

filterElements(elements, parametersopt, searchStringopt) → {Array.<$k.SemanticElement>}

Returns all elements that match the query

Parameters:
NameTypeAttributesDescription
elementsArray.<$k.SemanticElement>
parametersobject<optional>
searchStringstring<optional>
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:
Type: 
Array.<$k.SemanticElement>
Example
var hits = $k.Registry.query("experts").filterElements(persons);

filterHits(hits, parametersopt, searchStringopt) → {Array.<$k.Hit>}

Returns all hits that match the query

Parameters:
NameTypeAttributesDescription
hitsArray.<$k.Hit>
parametersobject<optional>
searchStringstring<optional>
Since
  • 5.3.0
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:
Type: 
Array.<$k.Hit>
Example
var hits = $k.Registry.query("experts").filterHits(hits);

findElements(parametersopt, searchStringopt) → {Array.<$k.SemanticElement>}

Search and return all found semantic elements

Parameters:
NameTypeAttributesDescription
parametersobject<optional>
searchStringstring<optional>
Inherited From
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:
Type: 
Array.<$k.SemanticElement>
Examples
var hits = $k.Registry.query("directSearch").findElements("Test");
var hits = $k.Registry.query("compositeSearch").findElements("Test", { context: "portal" });

findHits(parametersopt, searchStringopt) → {Array.<$k.Hit>}

Search and return all found hits.

Parameters:
NameTypeAttributesDescription
parametersobject<optional>
searchStringstring<optional>
Inherited From
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:
Type: 
Array.<$k.Hit>
Example
var hits = $k.Registry.query("directSearch").findHits("Test*");

findResultSize(parametersopt, searchStringopt) → {number}

Search and return the number of found semantic elements

Parameters:
NameTypeAttributesDescription
parametersobject<optional>
searchStringstring<optional>
Since
  • 5.3.3
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:
Type: 
number

findSolutions(parametersopt, singleElementIdentifiersopt) → {Array.<object>}

Search and return all solutions

Parameters:
NameTypeAttributesDescription
parametersobject<optional>
singleElementIdentifiersarray<optional>
Since
  • 5.2.2
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:

Each solution is an object containing an element of the result set, and all elements at identifiers of the query, e.g. {element: element1, identifiers: { someIdentifier1: [ element2, ... ], someIdentifier2: [ element3, ... ] }}. Each identifier in singleElementIdentifiers will be distribute multiple elements to one separate solution each

Type: 
Array.<object>

fullExplainElements(elements, parametersopt) → {Array.<$k.SemanticElement>}

Returns all elements involved in the query

Parameters:
NameTypeAttributesDescription
elementsArray.<$k.SemanticElement>

Elements to full explain. Elements that do not match the query are ignored.

parametersobject<optional>
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:
Type: 
Array.<$k.SemanticElement>

handleConditions(handle) → {Array.<$k.QueryCondition>}

Parameters:
NameTypeDescription
handlestring
Version
  • Experimental feature, might be removed at any time
Since
  • 5.4.2
Returns:

Handle conditions with the given handle

Type: 
Array.<$k.QueryCondition>

inheritance() → {boolean}

Returns true if elements of subdomains should be returned

Since
  • 4.1.0
Returns:
Type: 
boolean

inverseConditions() → {Array.<QueryConditon>}

Returns the conditions pointing to this query

Since
  • 4.1.0
Returns:
Type: 
Array.<QueryConditon>

name() → {string}

Returns the name

Inherited From
Returns:
Type: 
string

parentFolders() → {Array.<$k.Folder>}

Returns the folders that contain this element

Returns:
Type: 
Array.<$k.Folder>

renderElements(tableConfiguration, keyFilteropt, detailFilteropt) → {Array.<object>}

Search and render found semantic elements using the given table configuration

Parameters:
NameTypeAttributesDescription
tableConfiguration$k.TableConfiguration
keyFilterobject<optional>

Alternative 1 (preferred): a $k.JSONRenderContext Alternative 2 (compatibility only): A filter. See $k.JSONRenderContext.prototype.setFilters().

detailFilterobject<optional>

Only used if the key filter is not a $k.JSONRenderContext. See $k.JSONRenderContext.prototype.setLevelsOfDetail()

Since
  • 4.1.0
Deprecated
  • This function is deprecated and might be removed in future releases
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:

The rendered objects

Type: 
Array.<object>

renderHits(tableConfiguration, keyFilteropt, detailFilteropt) → {Array.<object>}

Search and render found hits using the given table configuration

Parameters:
NameTypeAttributesDescription
tableConfiguration$k.TableConfiguration
keyFilterobject<optional>

Alternative 1 (preferred): a $k.JSONRenderContext Alternative 2 (compatibility only): A filter. See $k.JSONRenderContext.prototype.setFilters().

detailFilterobject<optional>

Only used if the key filter is not a $k.JSONRenderContext. See $k.JSONRenderContext.prototype.setLevelsOfDetail()

Since
  • 4.1.0
Inherited From
Deprecated
  • This function is deprecated and might be removed in future releases
Throws:

When the query could not be solved, e.g. missing parameters

Type
$k.exception.QueryError
Returns:

The rendered objects

Type: 
Array.<object>

searchString() → {string}

Returns the search string

Inherited From
Returns:
Type: 
string

setAccessParameter(accessParameter, value)

Set a parameter of the query.

Parameters:
NameTypeDescription
accessParameterstring

One of the access parameters ("topic", "property", "accessedObject", "concept", "user" etc)

value

The value of the parameter. The type (string etc.) depends on the parameter. Arrays of values can be passed, too. The value undefined or null disables the parametrized condition.

Throws:

When the value is not suitable for the parameter

Type
$k.exception.TypeError

setAlternatives(conditions)

Set the conditions as alternatives (OR group). If <= 1 conditions are passed this will be a no-op.

Parameters:
NameTypeDescription
conditionsArray.<$k.QueryCondition>

Conditions of this query that should be alternatives

Since
  • 4.1.0
Deprecated
  • Use addAlternativeGroup() instead
Throws:

setDomain(domains)

Restrict the query results to objects/types of the domains

Parameters:
NameTypeDescription
domains$k.Domain

The domain or internal name of a type

Since
  • 4.1.0
Inherited From

setDomains(domains)

Restrict the query results to objects/types of the domains

Parameters:
NameTypeDescription
domainsArray.<$k.Domain>

The domains or internal names of types

Inherited From

setFacetFilters(facetFiltersArray)

Set the selected facets and terms for the query

Parameters:
NameTypeDescription
facetFiltersArrayarray

Array with selected facets and terms

Since
  • 5.1.3

setInheritance(useInheritance)

Set to false if elements of subdomains should not be returned

Parameters:
NameTypeDescription
useInheritanceboolean
Since
  • 4.1.0

setMergeCauses(mergeCauses)

Determines whether causes should be merged when filtering hits

Parameters:
NameTypeDescription
mergeCausesboolean
Version
  • Experimental feature, might be removed at any time
Since
  • 5.3.0

setName(name)

Sets the name of the query

Parameters:
NameTypeDescription
namestring

The name

Version
  • Experimental feature, might be removed at any time
Since
  • 5.3.2
Inherited From

setParameter(parameterId, value)

Set a parameter of the query.

Parameters:
NameTypeDescription
parameterIdstring

The ID of the parameter

value

The value of the parameter. The type (string etc.) depends on the parameter. Arrays of values can be passed, too. The value undefined or null disables the parametrized condition.

Inherited From
Throws:

When the value is not suitable for the parameter

Type
$k.exception.TypeError

setParameters(parameters)

Set the parameters of the query from the properties of the object

Parameters:
NameTypeDescription
parameters

The parameters

Throws:

When a value is not a suitable parameter

Type
$k.exception.TypeError

setSearchString(searchString)

Set the string to search for

Parameters:
NameTypeDescription
searchStringstring