Support NOT lucene queries and escape whitespace
This commit is contained in:
parent
35f9dcf3f6
commit
3a601d76ce
|
@ -34,6 +34,7 @@ class QueryBuilder {
|
|||
fuzzy: {},
|
||||
range: {},
|
||||
equal: {},
|
||||
notEqual: {},
|
||||
...base,
|
||||
}
|
||||
this.limit = 50
|
||||
|
@ -73,6 +74,11 @@ class QueryBuilder {
|
|||
return this
|
||||
}
|
||||
|
||||
addNotEqual(key, value) {
|
||||
this.query.notEqual[key] = value
|
||||
return this
|
||||
}
|
||||
|
||||
addTable(tableId) {
|
||||
this.query.equal.tableId = tableId
|
||||
return this
|
||||
|
@ -85,7 +91,7 @@ class QueryBuilder {
|
|||
if (output.length !== 0) {
|
||||
output += " AND "
|
||||
}
|
||||
output += queryFn(key, value)
|
||||
output += queryFn(key, value).replace(/ /, "\\ ")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,6 +110,9 @@ class QueryBuilder {
|
|||
if (this.query.equal) {
|
||||
build(this.query.equal, (key, value) => `${key}:${value}`)
|
||||
}
|
||||
if (this.query.notEqual) {
|
||||
build(this.query.notEqual, (key, value) => `!${key}:${value}`)
|
||||
}
|
||||
if (rawQuery) {
|
||||
output = output.length === 0 ? rawQuery : `&${rawQuery}`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue