@patarapolw/qsearch
v1.2.2
Published
Search a database with a string. Designed for end-users.
Downloads
3
Readme
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.
a
andA
means the same thing. +expression
means exactly match, and case-sensitive.-expression
means negation.- Not only
:
, but also>
and<
is used to specify comparison. For example,+foo:bar
,count>1
. NULL
is a special keyword, meaning, not exists,undefined
, ornull
.TRUE
andFALSE
are special keywords, meaning,true
andfalse
, respectively.- Date comparison is enabled.
- Special keyword:
NOW
. +1h
means next 1 hour.-1h
mean 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:duplicate
can 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