https://github.com/mlipscombe/postgraphile-plugin-zombodb
PostGraphile plugin for full text searching using ZomboDB
https://github.com/mlipscombe/postgraphile-plugin-zombodb
Last synced: 5 months ago
JSON representation
PostGraphile plugin for full text searching using ZomboDB
- Host: GitHub
- URL: https://github.com/mlipscombe/postgraphile-plugin-zombodb
- Owner: mlipscombe
- License: mit
- Created: 2019-01-12T07:05:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-16T21:17:58.000Z (about 7 years ago)
- Last Synced: 2025-10-26T14:46:28.407Z (8 months ago)
- Language: JavaScript
- Size: 86.9 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/postgraphile-plugin-zombodb)
[](https://circleci.com/gh/mlipscombe/postgraphile-plugin-zombodb/tree/master)
# postgraphile-plugin-zombodb
This plugin implements a full text search operator for tables that have a
[ZomboDB](https://github.com/zombodb/zombodb) index, using [Elasticsearch](https://www.elastic.co/).
## Getting Started
### CLI
``` bash
postgraphile --append-plugins postgraphile-plugin-zombodb
```
See [here](https://www.graphile.org/postgraphile/extending/#loading-additional-plugins) for
more information about loading plugins with PostGraphile.
### Library
``` js
const express = require('express');
const { postgraphile } = require('postgraphile');
const PostGraphileZomboDBPlugin = require('postgraphile-plugin-zombodb');
const app = express();
app.use(
postgraphile(pgConfig, schema, {
appendPlugins: [
PostGraphileZomboDBPlugin,
],
})
);
app.listen(5000);
```
## Schema
The plugin discovers all `ZomboDB` indexes and adds a `search` input argument for
each table with an index. For help with getting started with ZomboDB, check out the [tutorial](https://github.com/zombodb/zombodb/blob/master/TUTORIAL.md).
## Searching
The plugin passes the search string directly to the ZomboDB extension. See ZomboDB's [Query DSL documentation](https://github.com/zombodb/zombodb/blob/master/QUERY-DSL.md) for how to structure queries.
## Scoring
A `Float` score column will be automatically added to the GraphQL type for each indexed table, named `_score` by default.
This score field can be used for ordering and is automatically added to the orderBy
enum for the table.
## Examples
``` graphql
query {
allPosts(
search: {
query: "+cat and +dog"
minScore: 0.5
}
orderBy: _SCORE_DESC
}) {
...
_score
}
}
```
## To Do
* This plugin does not yet map `limit`/`offset` and `order by` parameters into
[ZomboDB's query DSL](https://github.com/zombodb/zombodb/blob/master/QUERY-DSL.md),
and so searches on huge tables may not be particularly performant.
* Match highlighting.
* Structured queries.