API:Search and discovery/de

MediaWiki, seine Erweiterungen und und seine Schwesterprojekte bieten enormes Potenzial, um Wissen durch Suchen zu entdecken. Das Search-Platform-Team entwickelt den Mechanismus, Werkzeuge und Dienste, um dies zu tun.

Benutzer können Informationen in MediaWiki finden, indem sie sie direkt suchen und in Wikidata, indem sie Help:Navigation in Wikidata lesen.

MediaWiki
Die MediaWiki API hat unterschiedliche Module mit Bezug zu Suchen. Du kannst am -Eingangspunkt jedes Wikis Abfragen stellen und dir die generierte Hilfe ansehen oder auf Special:ApiSandbox API-Abfrageparameter eintragen.

Suchmodule

 * action=opensearch
 * Siehe . Gibt Suchergebnisse im OpenSearch-Format aus, jeweils mit in Wikimedia-Projekten. Generierte API-Hilfe ansehen


 * action=languagesearch
 * Nach Sprachnamen in einem beliebigen Skript suchen. Generierte API-Hilfe ansehen

Abfragelisten-Submodule
Diese Abfrage-Submodule geben eine Liste von Wiki-Seiten aus, die Such-Kriterien erfüllen und geben teilweise zusätzliche Informationen über jede Seite aus. Furthermore, you can use each as a generator to provide many other Properties of the set of returned pages, such as a lead image, snippet, and/or page description.


 * action=query list=prefixsearch
 * Retrieves wiki page titles with the given prefix. See the showcase article Page info in search results. See module documentation for and View generated API help.


 * action=query list=search
 * Uses the wiki search engine to find matching pages. On Wikimedia wikis it provides search results from CirrusSearch, returning typical search result information such as text snippets and page size. See module documentation for and View generated API help


 * action=query list=geosearch
 * If the GeoData extension is installed on the wiki, then this returns wiki pages near a location, with their geographical information. See the showcase article Showing nearby wiki information, module documentation for geosearch, and View generated API help.

Kommandozeile
From the command line you can query the API using cURL to make the API request, then use jq to parse the JSON response.

For example, let's try looking up item on Wikidata, and request its English-language label:

We find that Q39246 is the Wikidata identifier for the item with English label "Richard Feynman", and that there are 55 claims made about him.

JavaScript
To write a MediaWiki API client in JavaScript, all that's needed is a JSONP handler. Many libraries (e.g. jQuery) include JSONP clients, or one can be written independently.

Within the MediaWiki ecosystem, jQuery can be used directly:

This uses jQuery's  which is available in many interactive JavaScript coding environments and makes sense if your eventual goal is a separate standalone project.

If your eventual goal is code running on a wiki, e.g. as a Gadget, then you should use the higher-level  function provided by the 'mediawiki.api' ResourceLoader module.

In other environments, a simple JSONP handler can be written:

CirrusSearch
CirrusSearch is a MediaWiki extension to enable Elastic-based search of MediaWiki content. It acts as a search back-end, so  is the main interface to this.

You can use the same Cirrus features in API queries that users can enter in the search box. For example, you can use the  special prefix to find related pages.

Additional CirrusSearch API modules
In addition, CirrusSearch can report its configuration and internal information. These APIs are probably only useful if you're familiar with Elasticsearch and want to see how CirrusSearch uses it. These are all considered internal debugging API's and no guarantees are made with regards to backwards compatability of changes to their output.


 * Seitenparameter
 * Zum Beispiel https://en.wikipedia.org/wiki/2014?action=cirrusdump


 * parameter to Special:Search queries
 * This is an action parameter to index.php, for example https://en.wikipedia.org/wiki/Special:Search/cat%20dog%20chicken?cirrusDumpQuery


 * parameter to Special:Search queries
 * This is an action parameter to index.php, for example https://en.wikipedia.org/wiki/Special:Search/cat%20dog%20chicken?cirrusDumpResult
 * An additional parameter,, can be passed with   to have the lucene explanation of the the score included with the result dump. For example https://en.wikipedia.org/wiki/Special:Search/cat%20dog%20chicken?cirrusDumpResult&cirrusExplain


 * API-Module cirrus-config-dump, cirrus-settings-dump, cirrus-mapping-dump
 * These dump the CirrusSearch setup.

Wikidata
Wikidata's API includes a few actions (wbgetentities, wbgetclaims, wbsearchentities) that can be used to search for information about entities, properties, statements, and claims.

Wikidata-Abfragedienst
performs graph-based searching of via a SPARQL API. It's available at https://query.wikidata.org/

WDQS Explorer (demo) (source code) provides in-browser graph exploration using SPARQL queries against the Wikidata Query Service.

Wikipedia
Browse to https://en.wikipedia.org/wiki/Main_Page, open up the JavaScript console, and run the following:

This logs the string  to the JavaScript console.

If the MediaWiki libraries and environment are unavailable, this can be done using the  function above:

Wikidata
Using JSONP, we can perform the above steps right from the Web browser's JavaScript console. On Wikipedia, the Wikidata item identifier is available via the MediaWiki configuration value.

Browse to https://en.wikipedia.org/wiki/Richard_Feynman, open up the JavaScript console, and run the following:

This logs the string  and the Wikidata entry description string "American quantum physicist" to the JavaScript console.

If the MediaWiki libraries and environment are unavailable, this can be done using the  function above:

Wiktionary
Browse to https://en.wikipedia.org/wiki/Main_Page, open up the JavaScript console, and run the following:

This logs the string  to the JavaScript console.

If the MediaWiki libraries and environment are unavailable, this can be done using the  function above: