<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://shifti.org/index.php?action=history&amp;feed=atom&amp;title=Help%3ASemantic_search</id>
	<title>Help:Semantic search - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://shifti.org/index.php?action=history&amp;feed=atom&amp;title=Help%3ASemantic_search"/>
	<link rel="alternate" type="text/html" href="https://shifti.org/index.php?title=Help:Semantic_search&amp;action=history"/>
	<updated>2026-08-25T15:13:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0-alpha</generator>
	<entry>
		<id>https://shifti.org/index.php?title=Help:Semantic_search&amp;diff=10287&amp;oldid=prev</id>
		<title>ShadowWolf: creating another help page for the semantic extensions - this time all about how to use it&#039;s search facilities</title>
		<link rel="alternate" type="text/html" href="https://shifti.org/index.php?title=Help:Semantic_search&amp;diff=10287&amp;oldid=prev"/>
		<updated>2009-02-14T22:59:49Z</updated>

		<summary type="html">&lt;p&gt;creating another help page for the semantic extensions - this time all about how to use it&amp;#039;s search facilities&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Semantic properties are useless if you can&amp;#039;t use them in some way, so the creators of the [http://semantic-mediawiki.org Semantic MediaWiki] extension have provided three facilities for querying the database about them: [[Special:Ask|The &amp;#039;Ask&amp;#039; Special Page]],the &amp;lt;nowiki&amp;gt;{{#ask}}&amp;lt;/nowiki&amp;gt; parser function and the &amp;lt;nowiki&amp;gt;{{#show}}&amp;lt;/nowiki&amp;gt; parser function.&lt;br /&gt;
__TOC__{{help}}&lt;br /&gt;
== Special:Ask ==&lt;br /&gt;
=== Overview ===&lt;br /&gt;
This page has two panes &amp;amp;mdash; the left is where you enter your query and the right is where you can ask for it to output additional pieces of semantic information. The left pane expects the query in a certain format &amp;amp;mdash; it is almost a complete database query language, but the advanced features need not be used. On the other hand the right pane is much simpler, and while it also expects input to be in a certain format, it is not as complex as the query setting.&lt;br /&gt;
=== Queries ===&lt;br /&gt;
The queries are actually a bit simpler than I have made them sound, though constructing a proper query can be tricky. By default you just enter a series of terms&amp;amp;ndash;similar to what you are used to with [http://www.google.com Google] but the terms are required to be in a specific format&amp;amp;ndash;and the system will use the &amp;quot;AND&amp;quot; principle to find pages that match every one of the specified terms.&lt;br /&gt;
=== Extra Information ===&lt;br /&gt;
The right-hand page is meant to be used to detail extra properties you want displayed in the results. These are formatted as: ?&amp;amp;lt;property name&amp;amp;gt;&lt;br /&gt;
== &amp;lt;nowiki&amp;gt;{{#ask}}&amp;lt;/nowiki&amp;gt; ==&lt;br /&gt;
=== Overview ===&lt;br /&gt;
This is how you can create an &amp;quot;inline query&amp;quot; that is embedded on a page. The basic format of this really special tag is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;{{#ask: &amp;amp;lt;query&amp;amp;gt;&lt;br /&gt;
| ?&amp;amp;lt;property name&amp;amp;gt;&lt;br /&gt;
}}&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Specifically ===&lt;br /&gt;
The &amp;#039;query&amp;#039; parameter of the tag can be any valid query that you&amp;#039;d pass to [[Special:Ask]] and the &amp;#039;property name&amp;#039; parameters are what you would enter into the right-hand pane of the [[Special:Ask]] page.&lt;br /&gt;
&lt;br /&gt;
There are other parameters available and these let you specify the format of the output and a lot of other factors&amp;amp;hellip; An example of a quick&amp;amp;dirty query without any of the extra parameters is:&lt;br /&gt;
&amp;lt;nowiki&amp;gt;{{#ask: [[Category:Story]][[setting::Xanadu]][[author::ShadowWolf]] | ?title | ?setting | ?author }}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Which produces the following results:&lt;br /&gt;
{{#ask: [[Category:Story]][[setting::Xanadu]][[author::ShadowWolf]] | ?title | ?setting | ?author }}&lt;br /&gt;
But by adding the &amp;#039;format&amp;#039; parameter we get:&lt;br /&gt;
&amp;lt;nowiki&amp;gt;{{#ask: [[Category:Story]][[setting::Xanadu]][[author::ShadowWolf]] | ?title | ?setting | ?author | format=broadtable }}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Which generates:&lt;br /&gt;
{{#ask: [[Category:Story]][[setting::Xanadu]][[author::ShadowWolf]] | ?title | ?setting | ?author | format=broadtable }}&lt;br /&gt;
Big difference, no?&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;format&amp;#039; parameter and the demonstrated possible value for it of &amp;#039;broadtable&amp;#039; is just an example. See the [http://semantic-mediawiki.org/wiki/Help:Inline_queries Semantic MediaWiki Help Page] for more information on the possible values and more.&lt;br /&gt;
== &amp;lt;nowiki&amp;gt;{{#show}}&amp;lt;/nowiki&amp;gt; ==&lt;br /&gt;
The &amp;lt;nowiki&amp;gt;{{#show}}&amp;lt;/nowiki&amp;gt; parser function allows for directly inserting the results of a semantic query inline into a page. The basic format is the same as that of the &amp;lt;nowiki&amp;gt;{{#ask}}&amp;lt;/nowiki&amp;gt; function, with the exception that you give it a page name (what you&amp;#039;d put inside the double-brackets to create a link) instead of a query. For instance, if you want to know the setting of &amp;#039;[[User:ShadowWolf/Ripples in Time|Ripples in Time]]&amp;#039; you could just do &amp;lt;nowiki&amp;gt;{{#show: User:ShadowWolf/Ripples in Time|?setting}}&amp;lt;/nowiki&amp;gt; &amp;amp;mdash; {{#show: User:ShadowWolf/Ripples in Time|?setting}}&lt;br /&gt;
&lt;br /&gt;
A different form, and one that is slightly more powerful, is by using a special form of the &amp;lt;nowiki&amp;gt;{{#ask}}&amp;lt;/nowiki&amp;gt; &amp;amp;ndash; &amp;lt;nowiki&amp;gt;{{#ask:&amp;amp;lt;page link&amp;amp;gt;|?&amp;amp;lt;property&amp;amp;gt;=}}&amp;lt;/nowiki&amp;gt;. Taking the previous example, that would be &amp;lt;nowiki&amp;gt;{{#ask:[[User:ShadowWolf/Ripples in Time]]|?setting=}}&amp;lt;/nowiki&amp;gt; - which generates the result: {{#ask:[[User:ShadowWolf/Ripples in Time]]|?setting=}}&lt;br /&gt;
== General Information ==&lt;br /&gt;
=== Category Matches ===&lt;br /&gt;
To match against a category, you enter it in the same format you would use to add the category to a page&amp;amp;mdash;ie:&amp;lt;nowiki&amp;gt;[[Category:Story]]&amp;lt;/nowiki&amp;gt;. This will return every page that is either directly or indirectly&amp;lt;ref&amp;gt;Indirectly, in this case, means &amp;#039;is not in the category, but is in a sub-category (add as many sub-&amp;#039;s as you want) of that category&amp;lt;/ref&amp;gt; in that category.&lt;br /&gt;
=== Property Matches ===&lt;br /&gt;
Matching against properties is very similar&amp;amp;ndash;the format is &amp;lt;nowiki&amp;gt;[[&amp;amp;lt;property name&amp;amp;gt;::&amp;amp;lt;property value&amp;amp;gt;]]&amp;lt;/nowiki&amp;gt;.&amp;lt;ref&amp;gt;This is, technically, also the format for adding a property directly. However, because this creates links to pages with the name of the property value, we ask that you use the [[Template:SMW Base|Semantic Property Template]] (&amp;lt;nowiki&amp;gt;{{SMW Base}}&amp;lt;/nowiki&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
=== Comparisons ===&lt;br /&gt;
Say, for instance, you want to match every page that is fiction and not in the [[Paradise (setting)|Paradise]] setting&amp;amp;ndash;with just property matches and category matches this isn&amp;#039;t possible. However there is a way to do it&amp;amp;mdash;by using a &amp;#039;comparison operator&amp;#039;. The solution to the problem I set would be to have &amp;lt;nowiki&amp;gt;[[setting::!Paradise]]&amp;lt;/nowiki&amp;gt; as one of the terms. The available comparison operators are:&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;&amp;amp;lt;&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;The value is less than the specified value. (&amp;lt;nowiki&amp;gt;[[height::&amp;lt;6 ft]]&amp;lt;/nowiki&amp;gt;, for instance, would match any &amp;#039;height&amp;#039; property that was set to a value under six feet.&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;&amp;amp;gt;&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;The exact opposite of the &amp;#039;less than&amp;#039; operator.&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;!&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;The value is not the same as what the property is set to. (see the opening example)&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;dt&amp;gt;~&amp;lt;/dt&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;This is the &amp;quot;similarity&amp;quot; operator, used for matching a small piece of text in a larger value. (&amp;lt;nowiki&amp;gt;[[name::~*Xanadu*]]&amp;lt;/nowiki&amp;gt; would match all properties that had the word &amp;#039;Xanadu&amp;#039; in them)&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
=== Wildcards ===&lt;br /&gt;
There is only one wildcard defined for matching semantic properties and that is the plus sign (+). It is used to mean &amp;#039;any value&amp;#039; &amp;amp;ndash; ie: &amp;lt;nowiki&amp;gt;[[setting::+]]&amp;lt;/nowiki&amp;gt; would match any page that had the &amp;#039;setting&amp;#039; property set.&lt;br /&gt;
=== Alternation ===&lt;br /&gt;
If you want to match a series of properties&amp;amp;mdash;perhaps you&amp;#039;re looking for a story that is either set in [[Xanadu (setting)|Xanadu]] or [[Paradise (setting)|Paradise]] then the &amp;#039;AND&amp;#039; method that the most basic of searches occurs in won&amp;#039;t work&amp;amp;mdash;you need an &amp;#039;OR&amp;#039; type of search. To do that, simply put the word &amp;#039;OR&amp;#039;&amp;lt;ref&amp;gt;Yes, without the quotes :P&amp;lt;/ref&amp;gt; in between the terms.&lt;br /&gt;
&lt;br /&gt;
To simplify things you could format the above example as: &amp;lt;nowiki&amp;gt;[[setting::Paradise||Xanadu]]&amp;lt;/nowiki&amp;gt; &amp;amp;ndash; this form is what I&amp;#039;d recommend be used.&lt;br /&gt;
=== Namespace Restriction ===&lt;br /&gt;
On Shifti this isn&amp;#039;t that useful in general. However, if you are trying to spot a [[Special:SpecialPages|Special Page]] or a [[Help:Contents|Help Page]] then this will be very handy. To restrict a search to a namespace you&amp;#039;d add &amp;lt;nowiki&amp;gt;[[&amp;amp;lt;namespace name&amp;amp;gt;:+]]&amp;lt;/nowiki&amp;gt; to the list of search terms.(ie: to restrict the search to the &amp;#039;Help&amp;#039; namespace, you&amp;#039;d add &amp;lt;nowiki&amp;gt;[[Help:+]]&amp;lt;/nowiki&amp;gt; to the list of search terms)&lt;br /&gt;
=== Chained Queries ===&lt;br /&gt;
You can also &amp;#039;chain&amp;#039; queries together. Suppose, for a moment, that Shifti offered the same breadth of articles as [http://en.wikipedia.org Wikipedia] and you wanted to find a list of all actors born in Italy. You know there is a list of cities located in Italy and also know that there is a &amp;#039;born in&amp;#039; property, but the classic query syntax doesn&amp;#039;t let you feed the output of one query into another.&lt;br /&gt;
&lt;br /&gt;
By chaining the queries together you can solve this problem. The solution to the above problem would be a query with the terms: &amp;lt;nowiki&amp;gt;[[Category:Actor]] [[born in::&amp;amp;lt;q&amp;amp;gt;[[cities in::Italy]]&amp;amp;lt;/q&amp;amp;gt;]]&amp;lt;/nowiki&amp;gt;. Yes&amp;amp;mdash;the &amp;amp;lt;q&amp;amp;gt; tag gets wrapped around the query! And this can be nested to any depth. (ie: to extend the above to all of europe you&amp;#039;d just change the &amp;lt;nowiki&amp;gt;[[born in]]&amp;lt;/nowiki&amp;gt; term to: &amp;lt;nowiki&amp;gt;[[born in::&amp;amp;lt;q&amp;amp;gt;[[cities in::&amp;amp;lt;q&amp;amp;gt;[[countries in::Europe]]&amp;amp;lt;/q&amp;amp;gt;]]&amp;amp;lt;/q&amp;amp;gt;]]&amp;lt;/nowiki&amp;gt;)&lt;br /&gt;
=== Templates and Variables ===&lt;br /&gt;
Templates and Template Variables can be used in queries. You can just insert them into the &amp;quot;value&amp;quot; side of things when you want to use them.&amp;lt;ref&amp;gt;&amp;lt;nowiki&amp;gt;{{#vardefine}}&amp;lt;/nowiki&amp;gt; style variables could possibly be used, but there is no information available as to whether this is true or not, so we&amp;#039;d recommend you not use them in queries.&amp;lt;/ref&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>ShadowWolf</name></author>
	</entry>
</feed>