PHPackages                             mediawiki/opensearch-query - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mediawiki/opensearch-query

ActiveMediawiki-extension

mediawiki/opensearch-query
==========================

MediaWiki extension for querying OpenSearch indices (view-equivalent queries, query\_string full-text search) and single-document fetches from within wiki pages.

00PHP

Since Jul 31Pushed todayCompare

[ Source](https://github.com/toniher/OpenSearch_Query)[ Packagist](https://packagist.org/packages/mediawiki/opensearch-query)[ RSS](/packages/mediawiki-opensearch-query/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Extension for querying OpenSearch indices within a MediaWiki instance.

Formerly known as CouchDB\_Query. See [docs/migration-from-couchdb.md](docs/migration-from-couchdb.md)if you are upgrading from the CouchDB-backed version.

Requirements
------------

[](#requirements)

- MediaWiki 1.35 or later
- An OpenSearch cluster (2.x or later)

Installation
------------

[](#installation)

1. Clone or download this extension into your MediaWiki `extensions/` directory:

    ```
    git clone  extensions/OpenSearch_Query

    ```
2. Add the following to the **bottom** of your `LocalSettings.php`:

    ```
    wfLoadExtension( 'OpenSearch_Query' );
    ```
3. Configure the OpenSearch connection in `LocalSettings.php` after the `wfLoadExtension` line:

    ```
    $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;
    ```
4. Define the named queries your wiki will use. A view-equivalent query names an index and the field that plays the role of a CouchDB view key; a full-text query names an index and the fields to search:

    ```
    $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 includes
    ];

    $wgOpenSearch_Query['queries']['mydb']['text'] = [
        'index'      => 'mydb-docs',
        'textfields' => [ 'title^3', 'body' ],   // query_string fields, boosts allowed
        'source'     => [ 'title', 'body', 'pagename' ],
        'lenient'    => false,                    // true: don't error on query_string syntax
        'allowLeadingWildcard' => false,
    ];
    ```

    `queries[$db][$index]` also accepts a plain string, treated as `[ 'index' =>  ]`, for the simplest case.
5. Single-document fetches (`#OpenSearch_Query_field`-style lookups by id) use a separate connection block, since it is often a different index or cluster:

    ```
    $wgOpenSearch_Query['document']['mydb'] = [
        'host'     => 'localhost',
        'port'     => 9200,
        'protocol' => 'https',
        'index'    => 'mydb-docs',
    ];
    ```
6. When a hit's `_id` does not resolve to a MediaWiki page id (full-text results from a document store keyed some other way), name the `_source` field to use as the page name instead:

    ```
    $wgOpenSearch_Query['map']['mydb']['text']['pagename'] = 'title';
    ```

Usage
-----

[](#usage)

Two parser functions are available in wiki pages:

### `{{#OpenSearch_Query_table:}}`

[](#opensearch_query_table)

Renders a dynamic table populated from an OpenSearch query.

```
{{#OpenSearch_Query_table: index=coords | db=mydb | type=opensearch-query | limit=25 | fields=start,end }}

```

ParameterDescription`index`Query name, resolved against `queries[$db]``db`Connection identifier, resolved against `params[$db]` (default: current wiki's DB name)`type`API action to call: `opensearch-query` (view-equivalent) or `opensearch-search` (full text). The legacy `couchdb-query`, `couchdb-lucene-query`, `couchdb-nouveau-query` values still work.`limit`Maximum rows to return (default: 25)`fields`Comma-separated list of fields to display. Supports `*` (page name), `*link`, `#link` (link with `@...` and `Namespace:` stripped from the label), `*score`, `~field` (field rendered as a link), `#field` (as `~field`, but also strips `@...`/`Namespace:` from the label)`raw`Comma-separated list of field names to render unescaped. All other field values are HTML-escaped by default`query`Query template. `$1` is replaced with the current search text; `javascript:funcName` dispatches to `window.opensearchjsfunc.funcName(text)` (falls back to the legacy `window.couchjsfunc`)`text`Initial value for the search input`start` / `end`Passed through as `startkey` / `endkey` for view-equivalent queries`header`Column header label(s), comma-separated (default: `Page name`)`class`CSS class for the table (default: `wikitable sortable jquery-tablesorter`)`prefix``field:value,...` - prepends `value:` to the named field before display`prefixurl``field:urlbase,...` - link base to use for `~field` / `#field``prefixcondurl``field:otherfield@value=urlbase,...` - link base for `~field` / `#field`, chosen by the value of another field in the same result`extra`Comma-separated list of CSS selectors pointing at `{{#OpenSearch_Query_field}}` elements elsewhere on the page whose values are appended to the query`full`Set to `1` to retrieve the complete result set (paged internally via `search_after`) and paginate client-side### `{{#OpenSearch_Query_field:}}`

[](#opensearch_query_field)

Renders an input field that can be wired into a table's `extra` list.

```
{{#OpenSearch_Query_field: tag=input | type=text | query=field:$1 | id=myfield }}

```

ParameterDescription`tag`HTML tag to render (`input`, `select`, etc.)`type`Input type attribute`query`Query fragment substituted with this field's value and appended to the parent table's query`values`Predefined values, comma-separated (for `select`)`id`Element ID`class`CSS class (currently not applied to the rendered element - see docs/migration-from-couchdb.md)`default`Default selected value (for `select`)API Modules
-----------

[](#api-modules)

ModuleActionDescription`opensearch-query``api.php?action=opensearch-query`View-equivalent query: `key` / `keys` / `startkey` / `endkey` against `keyfield``opensearch-search``api.php?action=opensearch-search`Full-text `query_string` search over `textfields``opensearch-document``api.php?action=opensearch-document`Retrieve a single document by id`couchdb-query`, `couchdb-lucene-query`, `couchdb-nouveau-query`, `couchdb-document`same pathsDeprecated aliases of the above, kept for existing callers. Marked `isDeprecated()`.`opensearch-query` params: `index`, `db`, `key`, `keys` (JSON array), `startkey`, `endkey`, `fields`, `limit`, `skip`, `include_docs`. Response: `{ status, count, results[], groups[]? }`, each result `{ id, pagename, fields }`.

`opensearch-search` params: `index`, `db`, `q`, `limit`, `skip`, `sort`, `full`. Response: `{ status, count, results[], warning? }`, each result `{ id, score, pagename, fields }`. A malformed `q` (e.g. partially typed `query_string` syntax) yields `count: 0` plus a `warning`, not an API error.

`opensearch-document` params: `db`, `key`. Response: `{ status, count, results[] }`, the single result being the document's `_source` flattened alongside its `_id`.

### TODO

[](#todo)

- Migrate JavaScript to use a proper OpenSearch JS client instead of hand-built query\_string

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5218ca0754245ef120fb4ebc1c520616cb8339e5e4f81301e4906893859d5404?d=identicon)[toniher](/maintainers/toniher)

---

Top Contributors

[![toniher](https://avatars.githubusercontent.com/u/535539?v=4)](https://github.com/toniher "toniher (184 commits)")

### Embed Badge

![Health badge](/badges/mediawiki-opensearch-query/health.svg)

```
[![Health](https://phpackages.com/badges/mediawiki-opensearch-query/health.svg)](https://phpackages.com/packages/mediawiki-opensearch-query)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
