PHP code example of mediawiki / opensearch-query
1. Go to this page and download the library: Download mediawiki/opensearch-query library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mediawiki / opensearch-query example snippets
wfLoadExtension( 'OpenSearch_Query' );
$wgOpenSearch_Query['params']['mydb']['host'] = 'localhost';
$wgOpenSearch_Query['params']['mydb']['port'] = 9200;
$wgOpenSearch_Query['params']['mydb']['protocol'] = 'https';
$wgOpenSearch_Query['params']['mydb']['username'] = 'myuser'; // omit for an open cluster
$wgOpenSearch_Query['params']['mydb']['password'] = 'mypassword';
$wgOpenSearch_Query['params']['mydb']['timeout'] = 10; // read timeout, seconds
$wgOpenSearch_Query['params']['mydb']['connectTimeout'] = 5;
$wgOpenSearch_Query['queries']['mydb']['coords'] = [
'index' => 'mydb-coords', // OpenSearch index or alias
'keyfield' => 'chrom.keyword', // key / keys / startkey / endkey target
'groupfield' => 'chrom.keyword', // optional: terms aggregation, exposed as `groups`
'filter' => [ 'term' => [ 'type' => 'coord' ] ], // optional constant filter
'sort' => [ [ 'chrom.keyword' => 'asc' ] ], // optional, defaults to keyfield asc
'source' => [ 'chrom', 'start', 'end' ], // optional _source
$wgOpenSearch_Query['document']['mydb'] = [
'host' => 'localhost',
'port' => 9200,
'protocol' => 'https',
'index' => 'mydb-docs',
];
$wgOpenSearch_Query['map']['mydb']['text']['pagename'] = 'title';