8.4.2 • Published 3 months ago

pg-tsquery v8.4.2

Weekly downloads
2,904
License
ISC
Repository
github
Last release
3 months ago

Text-Search parser for PostgreSQL

npm version build status coverage status

Why?

Using pg's to_tsquery directly with user input can throw errors. plainto_tsquery sanitizes the user input, but it's very limited (it just puts an and between words), websearch_to_tsquery extends this behavior a little further only between double-quotes, with followedBy operator and negations.

This module allows customizable text-search operators: and, or, followedBy, not, prefix, parentheses, quoted text (same behavior than websearch_to_tsquery).

See the options defaults values

usage

const tsquery = require('pg-tsquery')(/* options can be passed to override the defaults */);

pool.query('SELECT * FROM tabby WHERE to_tsvector(col) @@ to_tsquery($1)', [tsquery(str)]);

// or get a reusable instance
const {Tsquery} = require('pg-tsquery');

const parser = new Tsquery(/* options can be passed to override the defaults */);

// then process your input with parser.parse(str).toString()
inputsoutput
foo barfoo&bar
foo -bar, foo !bar, foo + !barfoo&!bar
foo bar,bip, foo+bar \| bipfoo&bar\|bip
foo (bar,bip), foo+(bar\|bip)foo&(bar\|bip)
foo>bar>bipfoo<->bar<->bip
foo*,bar* bana:*foo:*\|bar:*&bana:*

Demo

Support

Please consider reporting issues and trying to create a pull request as well

8.4.2

3 months ago

8.4.1

1 year ago

8.4.0

2 years ago

8.3.0

3 years ago

8.2.0

3 years ago

8.1.0

4 years ago

8.0.5

5 years ago

8.0.4

5 years ago

8.0.3

5 years ago

8.0.2

5 years ago

8.0.1

5 years ago

8.0.0

5 years ago

7.0.0

5 years ago

7.0.0-2

5 years ago

7.0.0-1

5 years ago

6.7.2

5 years ago

7.0.0-0

5 years ago

6.7.1

6 years ago

6.7.0

6 years ago

6.6.1

6 years ago

6.6.0

6 years ago

6.5.0

6 years ago

6.4.2

6 years ago

6.4.1

6 years ago

6.4.0

6 years ago

6.3.0

6 years ago

6.2.3

6 years ago

6.2.2

6 years ago

6.2.1

6 years ago

6.2.0

6 years ago

6.1.2

6 years ago

6.1.1

6 years ago

6.1.0

6 years ago

6.0.1

6 years ago

6.0.0

6 years ago

5.0.1

7 years ago

5.0.0

7 years ago

4.0.3

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

2.0.1

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago