MediaWiki:WikibaseFacetedSearch
sitelinkSiteId | null | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
itemTypeProperty | "P1" | ||||||||||||||||||||||||||||||||
configPerItemType |
|
Configure Tab Headers
Item | Tab Header |
---|---|
Q91 (human) | No tab header defined Create |
Q804 (creative work) | No tab header defined Create |
You can add a label to an item type by editing the MediaWiki:WikibaseFacetedSearch-item-type-{Q}
page.
Replace {Q}
with the Q-ID of the item type (MediaWiki:WikibaseFacetedSearch-item-type-Q1
for Q1
).
To add a label in a different language, edit the subpage of the page you created above (MediaWiki:WikibaseFacetedSearch-item-type-Q1/de
for German).
Configuration Documentation
The configuration defined on this page affects the search interface.
Besides the configuration reference below, you can consult the Wikibase Faceted Search documentation.
Table of Contents
Item Type Property
The Property ID of the "item type" (often "instance of") property.
Example configuration:
{ "itemTypeProperty": "P31" }
This is used to filter results for the tabs. The Property ID is combined with the
Item IDs that are keys in the configPerItemType
map part of the item types configuration.
For instance, a tab might filter for items where P31 is Q1, if Q1 is the key in the map.
Item Types (Tabs)
Defines the tabs that are shown in the search interface.
Each tab shows only items of a specific type. An items type is determined by the value its Statements for the "item type" Property.
Suppose you have Q1 that represents a "Person" and Q2 that represents a "City". This is minimal configuration to show both tabs:
"configPerItemType": { "Q1": {}, "Q2": {} }
Per item type you can configure an optional icon and an optional list of facets.
"configPerItemType": { "Q1": { "icon": "user", "facets": {} } }
The facets define one or more facets that are shown on the tab. See the Facets section for more information.
The icon is a string that represents a Font Awesome icon. They will only show up if Font Awesome is loaded. Some MediaWiki skins like Chameleon load Font Awesome by default. For other skins you have to load it yourself, which can be done in several ways, one of which is via the FontAwesome MediaWiki extension.
Facets
Facets are defined per item type and are shown only in the tab for that item type.
They are defined inside of the facets
element inside of the configPerItemType
map.
See the Item Types section for more information.
The below example defines a tab for items of type Q1 (say "people") with a facet that allows filtering by the value of property P42 (say "birth date") and a facet that allows filtering by the value of property P43 (say "occupation").
"configPerItemType": { "Q1": { "facets": { "P42": { "type": "range" }, "P43": { "type": "list" } } } }
There are two types of facets: range facets are list facets.
Range facets allow filtering numeric values by setting a minimum and/or maximum value. For instance, you could filter for people with a birth date before 1900 or a birth date between 1900 and 1950.
List facets show values that are present in the search results, together with the number of items that have that value. You can select one or more values to filter by.
List facets support both string and item values. If the value is an item, the label of the item is shown. if there is no label, the ID is shown.
List facets support the following optional configuration options:
-
defaultCombineWith
: The logical operator with which to combine multiple selected values. Either"AND"
or"OR"
. The default is"AND"
. -
allowCombineWithChoice
: If users should be able to change the logical operator to use via the UI. Eithertrue
orfalse
. The default istrue
. -
showAnyFilter
: If users should be able to filter items where the specific property has any value. Eithertrue
orfalse
. The default isfalse
. -
showNoneFilter
: If users should be able to filter items where the specific property does not have a value. Eithertrue
orfalse
. The default isfalse
.
Example list facet:
"P43": { "type": "list", "defaultCombineWith": "OR", "allowCombineWithChoice": false, "showAnyFilter": true, "showNoneFilter": true }
Use Wikitext Pages
This optional configuration is for wikis on which you have regular wiki pages (with wikitext) that represent items. For instance, an Author:Q1337 page that shows data from Item:Q1337. This approach is often used to provide a more user friendly view on Wikibase data. If you do not have such a wiki, this configuration should be omitted.
By default, Wikibase Faceted Search indexes your Wikibase Item pages. This means the search results will link to these Item pages.
You can use this configuration to instead index your Wikibase Item data on the wikitext pages. This means the search results will link to these wikitext pages instead of to the Item pages. It also means that you can combine structured search based on Wikibase values with full-text search for whatever is on your wikitext pages.
You will need to create sitelinks from the Wikibase Item pages to the wikitext pages. In the Wikibase Faceted Search configuration, you need to specify the site ID used in those sitelinks.
Example configuration:
{ "sitelinkSiteId": "enwiki" }
Full Example JSON
{ "sitelinkSiteId": "enwiki", "itemTypeProperty": "P42", "configPerItemType": { "Q100": { "icon": "person", "facets": { "P1": { "type": "list" }, "P2": { "type": "range" } } }, "Q200": { "icon": "book", "facets": { "P2": { "type": "range" }, "P3": { "type": "list", "defaultCombineWith": "OR", "allowCombineWithChoice": true, "showAnyFilter": true, "showNoneFilter": true } } } } }