NotContains internalSearch
This commit is contained in:
parent
47955b9b31
commit
93f60ec095
|
@ -39,7 +39,7 @@ export const OperatorOptions = {
|
||||||
label: "Contains",
|
label: "Contains",
|
||||||
},
|
},
|
||||||
NotContains: {
|
NotContains: {
|
||||||
value: "notEqual",
|
value: "notContains",
|
||||||
label: "Does Not Contain",
|
label: "Does Not Contain",
|
||||||
},
|
},
|
||||||
In: {
|
In: {
|
||||||
|
|
|
@ -20,6 +20,7 @@ class QueryBuilder {
|
||||||
notEmpty: {},
|
notEmpty: {},
|
||||||
oneOf: {},
|
oneOf: {},
|
||||||
contains: {},
|
contains: {},
|
||||||
|
notContains: {},
|
||||||
...base,
|
...base,
|
||||||
}
|
}
|
||||||
this.limit = 50
|
this.limit = 50
|
||||||
|
@ -125,6 +126,11 @@ class QueryBuilder {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addNotContains(key, value) {
|
||||||
|
this.query.notContains[key] = value
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preprocesses a value before going into a lucene search.
|
* Preprocesses a value before going into a lucene search.
|
||||||
* Transforms strings to lowercase and wraps strings and bools in quotes.
|
* Transforms strings to lowercase and wraps strings and bools in quotes.
|
||||||
|
@ -181,6 +187,10 @@ class QueryBuilder {
|
||||||
return `${key}:(${andStatement})`
|
return `${key}:(${andStatement})`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const notContains = (key, value) => {
|
||||||
|
return "*:* AND NOT " + contains(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
const oneOf = (key, value) => {
|
const oneOf = (key, value) => {
|
||||||
if (!Array.isArray(value)) {
|
if (!Array.isArray(value)) {
|
||||||
if (typeof value === "string") {
|
if (typeof value === "string") {
|
||||||
|
@ -279,6 +289,9 @@ class QueryBuilder {
|
||||||
if (this.query.contains) {
|
if (this.query.contains) {
|
||||||
build(this.query.contains, contains)
|
build(this.query.contains, contains)
|
||||||
}
|
}
|
||||||
|
if (this.query.notContains) {
|
||||||
|
build(this.query.notContains, notContains)
|
||||||
|
}
|
||||||
// make sure table ID is always added as an AND
|
// make sure table ID is always added as an AND
|
||||||
if (tableId) {
|
if (tableId) {
|
||||||
query = `(${query})`
|
query = `(${query})`
|
||||||
|
|
Loading…
Reference in New Issue