Help:Type Record/Searching a record

< Help:Datatype "Record"
Help:Datatype "Record"Help:Type Record/Searching a record

Semantic search[edit]

Using record properties for searching pages can be done in a similar fashion as for all other properties; see Semantic search. As with any property, you can use the + wildcard to select all pages with some value for a record property, for example {{#ask: [[Employment::+]] }}. To find pages that match a particular value for some of the fields of the record, just list the values to match, separated by semicolons. If you do not care about the value of one of the datatypes, use ? to match any value for it including omitted.

The values given for fields in a record query are written according to the datatype of the field. For most datatypes, this means that comparators such as ! for not, < for less than or equal to can be used with each field.

For example,

{{#ask: [[Employment:: ?; !professorship; <July 1950; ?]] }}

selects values for the property Employment with any value for the employer string, where the title string is not "professorship", the start date is before July 1950, and with any value for end date.

Regarding the printouts, there are 2 alternative methods to display the distinct field values of record properties:

  1. Either using the printout parameter index:
     |?Has president
     |?Has president=name |+index=1
     |?Has president=start |+index=2
     |?Has president=end |+index=3
  2. Or using the Help:Property_chains_and_paths syntax:1
     |?Has president
     |?Has president.Name= name
     |?Has president.Start date= start
     |?Has president.End date= end

The above hypothetical case assumes that country pages are annotated with multiple Has president record properties. The results would be like that:

  • 1st column: the complete record,
  • 2nd column: shows only the first field (name),
  • 3rd & 4th column: show that second and third fields, respectively, start and end of office.

Note that the only result of this query is the page "U.S.A" so the table has a single row that shows all of this page's values for Has president, not many rows for each president. The latter cannot be achieved with records.

Note also that this might result in some unintuitive query results. While SMW query constraints are applied to select matching Wiki pages:

 {{#ask: [[Employment:: ?; !professorship; <July 1950; ?]] }}

the final result set will contain all employments of these matching Wiki pages - even those which do not satisfy the query constraints - due to the way SMW deals with records in queries (i.e., query constraints are used to match pages, and in a second steps, all values of the property under consideration are returned - irrespective of if they satisfy query constraints).


  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:1824