Wikibase Faceted Search

Easily filter and find your Wikibase data

MediaWiki search page enhanced with faceted search including item type selectors, range filters, and list facets

On this page

External links

Faceted Search for Wikibase

Filter search results by statement values or item type.

Explore your Wikibase data with ease.

Wikibase Faceted Search enhances MediaWiki's search with faceted search capabilities. When searching for items, you can filter the results by the values of their statements via a sidebar.

The sidebar contains facets that show the most common values for each property, together with the number of items that have that value. You can build complex queries by selecting multiple values for the same property or different properties, including range queries, conjunctions (AND) and disjunctions (OR).

Wikibase Faceted Search requires Wikibase and CirrusSearch. See the installation instructions for more details.

Professional Wiki created Wikibase Faceted Search. We are Wikibase developers that provide professional Wikibase software development and Wikibase hosting.

We thank the NFDI-consortium MaRDI for funding initial development.

Usage documentation

Filtering Search Results

Once Wikibase Faceted Search is installed and configured, the standard search results page will show a tabbed UI. Each tab represents a type of item. For instance, there might be tabs for "Publications", "Authors", and "Events".

By selecting a tab, you limit the search results to items of that type. A sidebar will appear on the right side of the page with facets that allow you to filter the search results further.

The Query String

This documentation is only for advanced users. You do not need to understand what the query string is to use Wikibase Faceted Search.

Advanced users might wish to understand the query string, manipulate it directly, or use it in their own code. The query string is a string that represents the current state of the facets in the sidebar. It is used by the extension to filter search results.

Example query string:

foo haswbfacet:P1=Q123 haswbfacet:P2=a|b|c haswbfacet:P3

This query matches all pages that contain foo, have a statement for P1 with value Q123, have a statement for P2 with value a, b, or c, and have at least one statement for P3.

haswbfacet Keyword Reference

  • haswbfacet:P1 - There is at least one value for property P1
  • -haswbfacet:P1 - There is no value for property P1
  • haswbfacet:P1=A|B|C - There is at least one value for property P1 that is either A, B, or C
  • haswbfacet:P1=A haswbfacet:P1=B - P1 has at least one value that is A and at least one value that is B
  • haswbfacet:P1>2020 - P1 has at least one value that is greater than 2020
  • haswbfacet:P1<2020 haswbfacet:P1>2010 - P1 has at least one value that is between 2010 and 2020

Installation

Requirements

Load and enable

Load the extension using Composer:

COMPOSER=composer.local.json composer require --no-update professional-wiki/wikibase-faceted-search:~1.0

Enable the extension by adding the following to your LocalSettings.php:

wfLoadExtension( 'WikibaseFacetedSearch' );

Update MediaWiki database

Run the MediaWiki update.php script:

php maintenance/run.php update

You can verify the installation by checking your wiki's Special:Version page.

Configure

Because Wikibase Faceted Search only indexes Statements for Properties that are configured to have Facets, you need to finish your initial configuration before building the search index.

If you do not yet have Wikibase Properties, then you first have to create them. You can defer this step to a later time, though you will not get any facets until you have created the properties and specified them in the configuration.

View the configuration documentation.

Build Search Index

Run the following maintenance scripts to build the search index:

php extensions/CirrusSearch/maintenance/UpdateSearchIndexConfig.php
php extensions/CirrusSearch/maintenance/ForceSearchIndex.php --skipParse
php extensions/CirrusSearch/maintenance/ForceSearchIndex.php --skipLinks --indexOnSkip

You will need to re-run these whenever you add new properties to the configuration.

Configuration

If you install Wikibase Faceted Search without further configuration, your wiki will continue to work as before, but without the faceted search functionality.

How To Configure

Configuration is typically done via the in-wiki configuration page at MediaWiki:WikibaseFacetedSearch. A link to this page can be found in the Wikibase section on the Special:SpecialPages page. The configuration page takes a JSON string that defines the facets that should be shown in the sidebar. The page lists documentation for the configuration options.

You can also change configuration via LocalSettings.php via the wgWikibaseFacetedSearchConfig variable. It takes the same JSON string as the configuration page. Configuration on the configuration page will override the configuration in wgWikibaseFacetedSearchConfig. You can disable the configuration page by setting wgWikibaseFacetedSearchEnableInWikiConfig to false.

Many configuration changes require rebuilding the search index. Not rebuilding the search index after changing the configuration can lead to incorrect search results and incorrect information shown in the facets. It will not break your wiki, and previously configured facets will be unaffected. Thus, it is not absolutely critical to rebuild the search index immediately.

Key Configuration Capabilities

Item Types and Facets

Define what properties should have facets per item type. Example: Publications (P31=Q42) should have facets for Author (P1) and Year of Publication (P2)

Facet and Display Options

Define facet type and display options. For instance, you might wish to use a range facet for numeric properties.

Define UI labels for item types, optionally internationalized. Example: Q42 should be shown as "Publications" in the UI (even if the Wikibase label is "Publication")

Index Wikitext Via Sitelinks

Optionally, specify the Site ID of a Sitelink that points to wikitext pages in your wiki. This will make the wikitext page show up in the results instead of the Wikibase item. It also allows you to combine structured search via the facets with full-text search of whatever is shown on the wikitext page.

This is great for cases where you have "display pages" that show the information from a Wikibase item in a more readable format. For instance, a Author:Q1337 page that shows data from Item:Q1337.

Wikibase Hosting

Check out our tailored Wikibase hosting and Wikibase cloud hosting services.
Both include Wikibase Faceted Search and many other MediaWiki extensions.

Wikibase configuration section on the ProWiki Admin Panel

More MediaWiki Extensions

View all our extensions

Professional MediaWiki Services

MediaWiki services by the authors of Wikibase Faceted Search

Software Development icon
Software Development

Get superior results from the best MediaWiki developers with a proven track record of creating MediaWiki extensions & integrations.

Theme Development icon
Theme Development

Make your wiki look great! Use a time-tested responsive MediaWiki theme, or have us create a custom MediaWiki skin for you.

MediaWiki Hosting icon
MediaWiki Hosting

Let us take care of your wiki. We are MediaWiki hosting experts and provide cloud hosting, dedicated hosting, and on-premise hosting.

MediaWiki Consulting icon
MediaWiki Consulting

Bring your wiki to the next level by leveraging our MediaWiki expertise. From strategic planning to wikitext, we have you covered.

MediaWiki Migration icon
MediaWiki Migration

Migrate your wiki with confidence. We move your MediaWiki to a new home, or we help you migrate from another system to MediaWiki.

MediaWiki Upgrades icon
MediaWiki Upgrades

Keep your MediaWiki up-to-date and secure. We offer MediaWiki maintenance services to keep your wiki running smoothly.