Querying the CSDMS model repository: Difference between revisions

From CSDMS
m (Mpiper moved page Querying model metadata to Querying the CSDMS model repository without leaving a redirect: better name)
m (Remove level 1 header)
Line 1: Line 1:
= Querying the CSDMS Model Repository =
[https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki Semantic MediaWiki] (SMW)
[https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki Semantic MediaWiki] (SMW)
is the knowledge management system used on the [http://csdms.colorado.edu/wiki/Main_Page CSDMS website].
is the knowledge management system used on the [http://csdms.colorado.edu/wiki/Main_Page CSDMS website].

Revision as of 20:42, 8 March 2016

Semantic MediaWiki (SMW) is the knowledge management system used on the CSDMS website. SMW has an API with several actions, allowing users to add, edit, and query information. Here, we'll focus on the ask action, and the Ask API, to query metadata from the CSDMS model metadata repository.

The base URL for any call to the SMW API on the CSDMS website is http://csdms.colorado.edu/mediawiki/api.php.

Query syntax

The ask action supports one parameter, query, which takes an urlencoded string. The query is written in the SMW query language. A query consists of a series of conditions, which describe the search. Conditions are built from properties and values. For example, the condition

[[Programming language::C]]

would query for all models with the Programming language property that have a value of C. Note that the colons :: in the condition are literal in the query language, and cannot be urlencoded. Spaces, however, should be encoded with %20 or +, while brackets [] may optionally be encoded.

Try this condition in a query:

http://csdms.colorado.edu/mediawiki/api.php?action=ask&query=[[Programming+language::C]]&format=json

The results of a query are returned as JSON with a specified format. A query result can also be viewed in pretty print form by changing the value of the format parameter to jsonfm.


Properties

Properties are the basic data type of SMW. They consist of a name and a value, both of which are case-sensitive.

A defined set of properties are added to each model by the CSDMS WikiSysop. For example, Programming language is a property of models in the CSDMS model metadata repository.

Note: I desire a query that returns all the properties of a model, but I haven't figured out how to make it. It's on my list of unanswered questions below. In lieu of a programmatic query, I've been looking at the model's wiki source; for example, the Wikitext for HydroTrend.


Categories

Categories are tags added to a page by the CSDMS WikiSysop to aid in classification. Like properties, categories can be queried. For example, the condition

[[Category:Terrestrial]]

will list all terrestrial models the CSDMS model metadata repository. Unlike properties, only one colon : separates the category name and value.

Model is itself a category in the CSDMS wiki. Search for a particular model by name:

[[Model:HydroTrend]]

The category value is case-sensitive; e.g., hydrotrend wouldn't match a model. Here's this condition in a query:

http://csdms.colorado.edu/mediawiki/api.php?action=ask&query=[[Model:HydroTrend]]&format=json


Model keywords

Model keywords are defined not by SMW or the CSDMS WikiSysop, but by the developer of a model, so they may inconsistently vary from model to model. For example, the condition

[[Model keywords::basin]]

can be used to find all models that contain the keyword basin. Use this condition in a query:

http://csdms.colorado.edu/mediawiki/api.php?action=ask&query=[[Model+keywords::basin]]&format=jsonfm