#ask: syntax – "depth" hierarchy restrictor

From semantic-mediawiki.org
< #ask: syntax elements
#ask: syntax elements#ask: syntax – "depth" hierarchy restrictor
#ask: syntax details:
Syntax
+depth=
Description Restricts the hierarchy depth of a query1
Datatype support All datatypes
Component condition
Software Semantic MediaWiki
Since version Semantic MediaWiki 3.0.0 Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x.
Keyword hierarchy · depth restriction · property hierarchy · category hierarchy · class hierarchy · subcategory · subproperty · inferencing

The +depth= hierarchy depth restrictor was introduced in Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x..

Rationale[edit]

Semantic MediaWiki by default considers all subcategories and subproperties as part of a hierarchy when selecting pages. Limits settable with either configuration parameter $smwgQSubcategoryDepthSets the maximum level of subcategory inclusion (steps within category hierarchy) when querying or configuration parameter $smwgQSubpropertyDepthSets the maximum level of subproperty inclusion (steps within property hierarchy) apply to all queries within the respective wiki. To individually prevent selected inline queries using either the #ask or #show parser function to consider subcategories or subproperties the +depth= query parameter is used to set the levels for inferencing where a hierarchy is detectable.

The integer set with the +depth= query parameter denotes the maximum level for considering either the subcategories or subproperties. Setting "0" resolves only the category or property stated in the inline query. If this query parameter is not used all hierarchy levels are considered to the maximum extent either defined with configuration parameter $smwgQSubcategoryDepthSets the maximum level of subcategory inclusion (steps within category hierarchy) when querying or configuration parameter $smwgQSubpropertyDepthSets the maximum level of subproperty inclusion (steps within property hierarchy) which is the default behavior.

When using an RDF store setup with SPARQLStore via configuration parameter $smwgDefaultStoreSets the storage backend to be used for the semantic data this query parameter may only be set to either "0" or "1".

Example[edit]

Syntax for category inferencing
{{#ask:
 [[Category:Foo|+depth=0]]
 |?Category
}}
Syntax for property inferencing
{{#ask:
 [[SomeProperty::+|+depth=1]]
 |?SomeProperty
}}

or

{{#ask:
 [[SomeProperty::SomeValue|+depth=0]]
 |?SomeProperty
}}
Link

<sandbox.semantic-mediawiki.org>: More examples for this query parameter

See also[edit]

Specific information
Information on configuration parameters

References

  1. ^  Semantic MediaWiki: GitHub issue gh:smw:2662