All Projects → caub → pg-tsquery

caub / pg-tsquery

Licence: other
🔍 Parse user input into a valid PostgreSQL tsquery

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to pg-tsquery

ngp
Ncurses code parsing tool
Stars: ✭ 52 (+8.33%)
Mutual labels:  search-in-text
flashgeotext
Extract city and country mentions from Text like GeoText without regex, but FlashText, a Aho-Corasick implementation.
Stars: ✭ 53 (+10.42%)
Mutual labels:  search-in-text
textics
📉 JavaScript Text Statistics that counts lines, words, chars, and spaces.
Stars: ✭ 36 (-25%)
Mutual labels:  search-in-text
regXwild
⏱ Superfast ^Advanced wildcards++? | Unique algorithms that was implemented on native unmanaged C++ but easily accessible in .NET via Conari (with caching of 0x29 opcodes +optimizations) etc.
Stars: ✭ 20 (-58.33%)
Mutual labels:  search-in-text
note-cli
Markdown Indexing and Pcre Regular Expression Compatible Full Text Searching for Advanced Note Takers.
Stars: ✭ 15 (-68.75%)
Mutual labels:  search-in-text
laravel-scout-settings
DEPRECATED: Use of this repository is deprecated. Please use Scout Extended - https://github.com/algolia/scout-extended instead.
Stars: ✭ 23 (-52.08%)
Mutual labels:  search-in-text
sliceslice-rs
A fast implementation of single-pattern substring search using SIMD acceleration.
Stars: ✭ 66 (+37.5%)
Mutual labels:  search-in-text
bulksearch
Lightweight and read-write optimized full text search library.
Stars: ✭ 108 (+125%)
Mutual labels:  search-in-text
Ambar
🔍 Ambar: Document Search Engine
Stars: ✭ 1,829 (+3710.42%)
Mutual labels:  search-in-text
Flexsearch
Next-Generation full text search library for Browser and Node.js
Stars: ✭ 8,108 (+16791.67%)
Mutual labels:  search-in-text
The silver searcher
A code-searching tool similar to ack, but faster.
Stars: ✭ 23,030 (+47879.17%)
Mutual labels:  search-in-text
Flashtext
Extract Keywords from sentence or Replace keywords in sentences.
Stars: ✭ 5,012 (+10341.67%)
Mutual labels:  search-in-text
septum
Context-based code search tool
Stars: ✭ 25 (-47.92%)
Mutual labels:  search-in-text

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 one of those equivalent ways to process your input:
parser.parseAndStringify(str);
`${parser.parse(str) || ''}`;
inputs output
foo bar foo&bar
foo -bar, foo !bar, foo + !bar foo&!bar
foo bar,bip, foo+bar | bip foo&bar|bip
foo (bar,bip), foo+(bar|bip) foo&(bar|bip)
foo>bar>bip foo<->bar<->bip
foo*,bar* bana:* foo:*|bar:*&bana:*

Demo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].