1.2.2 • Published 6 years ago
@patarapolw/qsearch v1.2.2
QSearch
Search a database with a string. Designed for end-users.
Demo
See https://q2search.herokuapp.com
This demo also allows is:unique as a special operator.
See /web/backend/src/schema.ts and /web/backend/src/shared.ts for schema and search options, respectively.
This compares between MongoDB, LokiJS, NeDB, and native Array.filter.
Usage
This is inspired from lunr.js search by fields, if specified, with some major differences.
- Default connector is
AND. - To make an
OR, use?expression. - Search is normally case-insensitive, i.e.
aandAmeans the same thing. +expressionmeans exactly match, and case-sensitive.-expressionmeans negation.- Not only
:, but also>and<is used to specify comparison. For example,+foo:bar,count>1. NULLis a special keyword, meaning, not exists,undefined, ornull.TRUEandFALSEare special keywords, meaning,trueandfalse, respectively.- Date comparison is enabled.
- Special keyword:
NOW. +1hmeans next 1 hour.-1hmean 1 hour ago.- Available units are
y (year),M (month),w (week),d (day),h (hour),m (minute).
- Available units are
- Special keyword:
- Extra keywords, such as
is:duplicatecan be set. - Tested for loki.js, nedb, and MongoDB. Also, pure JavaScript Array filtering is possible too.
- For SQL's, you might need extra work to convert to queries, or just use NoSQL's.
- For now, fuzzy search is not supported.
Used in
This project is used in https://github.com/patarapolw/learn-unicode