Jump to content

MediaWiki:WikibaseFacetedSearch

From WBS
sitelinkSiteIdnull
itemTypeProperty"P1"
configPerItemType
Q91
facets
P55
type"list"
P56
type"range"
Q804
facets
P6
type"list"
P10
type"list"
P29
type"range"
P5
type"list"
P82
type"list"
P100
type"list"
P97
type"list"
P11
type"list"
Q10819
facets
P29
type"range"
P11
type"list"
Q11
facets
P6
type"list"
P10
type"list"
P29
type"range"
P5
type"list"
P82
type"list"
P100
type"list"
P97
type"list"
P11
type"list"
Q16
facets
P6
type"list"
P10
type"list"
P29
type"range"
P5
type"list"
P82
type"list"
P100
type"list"
P97
type"list"
P11
type"list"
Q364
facets
P29
type"range"
P11
type"list"
Q40
facets
P6
type"list"
P10
type"list"
P29
type"range"
P5
type"list"
P82
type"list"
P100
type"list"
P97
type"list"
P11
type"list"
Q41
facets
P29
type"range"
P11
type"list"
Q43
facets
P29
type"range"
P11
type"list"
Q44
facets
P29
type"range"
P11
type"list"
Q45
facets
P29
type"range"
P11
type"list"
Q46
facets
P29
type"range"
P11
type"list"
Q47
facets
P29
type"range"
P11
type"list"
Q48
facets
P29
type"range"
P11
type"list"
Q49
facets
P29
type"range"
P11
type"list"
Q50
facets
P29
type"range"
P11
type"list"
Q51
facets
P29
type"range"
P11
type"list"
Q52
facets
P29
type"range"
P11
type"list"
Q53
facets
P29
type"range"
P11
type"list"
Q54
facets
P29
type"range"
P11
type"list"
Q55
facets
P29
type"range"
P11
type"list"
Q56
facets
P29
type"range"
P11
type"list"
Q58
facets
P29
type"range"
P11
type"list"
Q59
facets
P29
type"range"
P11
type"list"
Q60
facets
P29
type"range"
P11
type"list"
Q61
facets
P29
type"range"
P11
type"list"
Q62
facets
P29
type"range"
P11
type"list"
Q63
facets
P29
type"range"
P11
type"list"
Q64
facets
P29
type"range"
P11
type"list"
Q6780
facets
P6
type"list"
P10
type"list"
P29
type"range"
P5
type"list"
P82
type"list"
P100
type"list"
P97
type"list"
P11
type"list"
Q6876
facets
P6
type"list"
P10
type"list"
P29
type"range"
P5
type"list"
P82
type"list"
P100
type"list"
P97
type"list"
P11
type"list"
Q7007
facets
P6
type"list"
P10
type"list"
P29
type"range"
P5
type"list"
P82
type"list"
P100
type"list"
P97
type"list"
P11
type"list"
Q7008
facets
P29
type"range"
P11
type"list"
Q802
facets
P6
type"list"
P10
type"list"
P29
type"range"
P5
type"list"
P82
type"list"
P100
type"list"
P97
type"list"
P11
type"list"

Configure Tab Headers

Item Tab Header
Q91 (human) No tab header defined Create
Q804 (creative work (generic)) No tab header defined Create
Q10819 (cdn-work) No tab header defined Create
Q11 (application) No tab header defined Create
Q16 (performance) No tab header defined Create
Q364 (master's thesis) No tab header defined Create
Q40 (anthology) No tab header defined Create
Q41 (news article) No tab header defined Create
Q43 (academic journal article) No tab header defined Create
Q44 (scholarly article) No tab header defined Create
Q45 (blog post) No tab header defined Create
Q46 (article) No tab header defined Create
Q47 (chapter) No tab header defined Create
Q48 (publication) No tab header defined Create
Q49 (monograph) No tab header defined Create
Q50 (habilitation thesis) No tab header defined Create
Q51 (doctoral thesis) No tab header defined Create
Q52 (conference paper) No tab header defined Create
Q53 (panel discussion) No tab header defined Create
Q54 (conference presentation) No tab header defined Create
Q55 (exhibition catalogue) No tab header defined Create
Q56 (review) No tab header defined Create
Q58 (interview) No tab header defined Create
Q59 (issue) No tab header defined Create
Q60 (keynote) No tab header defined Create
Q61 (draft document) No tab header defined Create
Q62 (white paper) No tab header defined Create
Q63 (sequence) No tab header defined Create
Q64 (video essay) No tab header defined Create
Q6780 (exhibit) No tab header defined Create
Q6876 (video game) No tab header defined Create
Q7007 (cdn-creative-work) No tab header defined Create
Q7008 (cdn-critical-writing) No tab header defined Create
Q802 (literary 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. Either true or false. The default is true.
  • showAnyFilter: If users should be able to filter items where the specific property has any value. Either true or false. The default is false.
  • showNoneFilter: If users should be able to filter items where the specific property does not have a value. Either true or false. The default is false.

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
				}
			}
		}
	}
}