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