$k. GQLQuery

Represents a GQL query

Constructor

new $k.GQLQuery(sourceopt)

Constructs a GQL query

Parameters:
NameTypeAttributesDescription
sourcestring<optional>

The query source

Since
  • 6.1.0
Throws:

If the query statement is not valid

Type
$k.exception.QueryError

Extends

Methods

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

Returns the parameters of the query

Since
  • 4.0.0
Returns:
Type: 
Array.<$k.QueryParameter>

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>

The parameters object where the keys match the names of parameters defined in the query

Since
  • 4.0.0
Throws:

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

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

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

Returns all elements that match the query. The two optional parameters can be given in any order.

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

The parameters object where the keys match the names of parameters defined in the query

Since
  • 4.0.0
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);

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

Search and return all found semantic elements. The two parameters can be given in any order.

Parameters:
NameTypeAttributesDescription
searchStringstring<optional>
parametersobject<optional>

The parameters object where the keys match the names of parameters defined in the query

Since
  • 4.0.0
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(searchStringopt, parametersopt) → {Array.<$k.Hit>}

Search and return all found hits. The two arguments can be given in any order.

Parameters:
NameTypeAttributesDescription
searchStringstring<optional>
parametersobject<optional>

The parameters object where the keys match the names of parameters defined in the query

Since
  • 4.0.0
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(searchStringopt, parametersopt) → {number}

Search and return the number of found semantic elements. The two arguments can be given in any order.

Parameters:
NameTypeAttributesDescription
searchStringstring<optional>
parametersobject<optional>

The parameters object where the keys match the names of parameters defined in the query

Since
  • 5.3.3
Throws:

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

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

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

Returns all elements involved in the query

Parameters:
NameTypeAttributesDescription
elementsArray.<$k.SemanticElement>

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

parametersobject<optional>

The parameters object where the keys match the names of parameters defined in the query

Since
  • 4.3.1
Throws:

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

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

name() → {string}

Returns the name

Since
  • 4.0.0
Inherited From
Returns:
Type: 
string

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

Returns the folders that contain this element

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

perform(searchStringopt, parametersopt) → {$k.GQLQueryResult}

Performs the query and returns a query result object

Parameters:
NameTypeAttributesDescription
searchStringstring<optional>
parametersobject<optional>

The parameters object where the keys match the names of parameters defined in the query

Version
  • Experimental feature, might be removed at any time
Since
  • 6.1.0
Throws:

When the query cannot be performed, e.g. missing parameters

Type
$k.exception.QueryError
Returns:

The query result

Type: 
$k.GQLQueryResult

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

Since
  • 4.0.0
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$k.SemanticElement | Array.<$k.SemanticElement>

The value of the parameter.

Version
  • Experimental feature, might be removed at any time
Since
  • 6.1.0

setDescription(description)

Sets the query description

Parameters:
NameTypeDescription
descriptionstring

The query description

Since
  • 6.1.0

setDomain(domain)

Restrict the query results to objects/types of the domains

Parameters:
NameTypeDescription
domain$k.Domain | string

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> | Array.<string>

The domains or internal names of types

Since
  • 4.0.0
Inherited From

setFacetFilters(facetFiltersArray)

Set the selected facets and terms for the query

Parameters:
NameTypeDescription
facetFiltersArrayArray.<object>

Array with selected facets and terms

Properties
NameTypeAttributesDefaultDescription
facetIdstring

Facet identifier

termIdsArray.<string><optional>

Term identifiers

showAllTermsboolean<optional>
false
Since
  • 5.1.3

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.

Version
  • Experimental feature, might be removed at any time
Since
  • 6.1.0
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
parametersobject

The parameters object where the keys match the names of parameters defined in the query

Version
  • Experimental feature, might be removed at any time
Since
  • 6.1.0
Throws:

When a value is not a suitable parameter

Type
$k.exception.TypeError

setSearchString(searchString)

Set the string to search for

Parameters:
NameTypeDescription
searchStringstring
Since
  • 4.0.0

setSource(source)

Sets the query source. A write transaction is required for modifying registered GQL queries.

Parameters:
NameTypeDescription
sourcestring

The new query source

Version
  • Experimental feature, might be removed at any time
Since
  • 6.1.0
Throws:

When this is a registered GQL query and no write transaction is active.

Type
$k.exception.TransactionError

source() → {string}

Returns the query source

Version
  • Experimental feature, might be removed at any time
Since
  • 6.1.0
Returns:
Type: 
string