PostGraphile plugin for full text searching using ZomboDB
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
__tests__
scripts
src
.editorconfig
.gitignore
LICENSE
README.md
index.js
package.json
yarn.lock

README.md

Package on npm CircleCI

postgraphile-plugin-zombodb

This plugin implements a full text search operator for tables that have a ZomboDB index, using Elasticsearch.

Getting Started

CLI

postgraphile --append-plugins postgraphile-plugin-zombodb

See here for more information about loading plugins with PostGraphile.

Library

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.

Searching

The plugin passes the search string directly to the ZomboDB extension. See ZomboDB's Query DSL documentation 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

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, and so searches on huge tables may not be particularly performant.
  • Match highlighting.
  • Structured queries.