1.0.0-beta.5 • Published 5 years ago

postgraphile-plugin-zombodb v1.0.0-beta.5

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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.