@yuanliwei/eui-search_bar-query
v1.0.0
Published
eui search_bar query
Downloads
1
Readme
EUI search_bar Query parser
- example
const Query = require('@yuanliwei/eui-search_bar-query')
function parse(param) {
console.log(param)
console.log(JSON.stringify(Query.toESQuery(Query.parse(param)), null, 4), '\n')
}
parse(`date>='2004-03-22'`)
parse(``)
parse(`-group:es group:kibana -group:beats group:logstash`)
parse(`is:online group:kibana john`)
parse(`john -doe is:online group:eng group:es -group:kibana -is:active`)
parse(`john -sales`)
parse(`john group:(eng or "marketing org") -group:"kibana team"`)
parse(`john group:(eng or es) -group:kibana`)
parse(`(name:john OR name:fred)`)
parse(`(name:john)`)
parse(`-count<=4 size<5 age>=3 -number>9`)
parse(`count>3`)
parse(`date:'2004-03' -date<'2004-03-10'`)
parse(`date>'2004-02' -otherDate>='2004-03-10'`)
parse(`date>='2004-03-22'`)
parse(`name:"First \\"Nickname\\" Last"`)
parse(`name:john (is:enrolled OR Teacher)`)
- output
date>='2004-03-22'
{
"bool": {
"must": [
{
"range": {
"date": {
"gte": "2004-03-22T00:00:00Z||/d"
}
}
}
]
}
}
{
"match_all": {}
}
-group:es group:kibana -group:beats group:logstash
{
"bool": {
"must": [
{
"match": {
"group": {
"query": "kibana logstash",
"operator": "and"
}
}
}
],
"must_not": [
{
"match": {
"group": {
"query": "es beats",
"operator": "and"
}
}
}
]
}
}
is:online group:kibana john
{
"bool": {
"must": [
{
"simple_query_string": {
"query": "john"
}
},
{
"match": {
"group": {
"query": "kibana",
"operator": "and"
}
}
},
{
"term": {
"online": true
}
}
]
}
}
john -doe is:online group:eng group:es -group:kibana -is:active
{
"bool": {
"must": [
{
"simple_query_string": {
"query": "john"
}
},
{
"match": {
"group": {
"query": "eng es",
"operator": "and"
}
}
},
{
"term": {
"online": true
}
},
{
"term": {
"active": false
}
}
],
"must_not": [
{
"simple_query_string": {
"query": "doe"
}
},
{
"match": {
"group": {
"query": "kibana",
"operator": "and"
}
}
}
]
}
}
john -sales
{
"bool": {
"must": [
{
"simple_query_string": {
"query": "john"
}
}
],
"must_not": [
{
"simple_query_string": {
"query": "sales"
}
}
]
}
}
john group:(eng or "marketing org") -group:"kibana team"
{
"bool": {
"must": [
{
"simple_query_string": {
"query": "john"
}
},
{
"bool": {
"should": [
{
"match": {
"group": {
"query": "eng",
"operator": "or"
}
}
},
{
"match_phrase": {
"group": "marketing org"
}
}
]
}
}
],
"must_not": [
{
"match_phrase": {
"group": "kibana team"
}
}
]
}
}
john group:(eng or es) -group:kibana
{
"bool": {
"must": [
{
"simple_query_string": {
"query": "john"
}
},
{
"match": {
"group": {
"query": "eng es",
"operator": "or"
}
}
}
],
"must_not": [
{
"match": {
"group": {
"query": "kibana",
"operator": "and"
}
}
}
]
}
}
(name:john OR name:fred)
{
"bool": {
"must": [
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"match": {
"name": {
"query": "john",
"operator": "and"
}
}
}
]
}
},
{
"bool": {
"must": [
{
"match": {
"name": {
"query": "fred",
"operator": "and"
}
}
}
]
}
}
]
}
}
]
}
}
(name:john)
{
"bool": {
"must": [
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"match": {
"name": {
"query": "john",
"operator": "and"
}
}
}
]
}
}
]
}
}
]
}
}
-count<=4 size<5 age>=3 -number>9
{
"bool": {
"must": [
{
"range": {
"size": {
"lt": 5
}
}
},
{
"range": {
"age": {
"gte": 3
}
}
}
],
"must_not": [
{
"range": {
"count": {
"lte": 4
}
}
},
{
"range": {
"number": {
"gt": 9
}
}
}
]
}
}
count>3
{
"bool": {
"must": [
{
"range": {
"count": {
"gt": 3
}
}
}
]
}
}
date:'2004-03' -date<'2004-03-10'
{
"bool": {
"must": [
{
"match": {
"date": "2004-03-01T00:00:00Z||/M"
}
}
],
"must_not": [
{
"range": {
"date": {
"lt": "2004-03-10T00:00:00Z||/d"
}
}
}
]
}
}
date>'2004-02' -otherDate>='2004-03-10'
{
"bool": {
"must": [
{
"range": {
"date": {
"gte": "2004-02-01T00:00:00Z||+1M/M"
}
}
}
],
"must_not": [
{
"range": {
"otherDate": {
"gte": "2004-03-10T00:00:00Z||/d"
}
}
}
]
}
}
date>='2004-03-22'
{
"bool": {
"must": [
{
"range": {
"date": {
"gte": "2004-03-22T00:00:00Z||/d"
}
}
}
]
}
}
name:"First \"Nickname\" Last"
{
"bool": {
"must": [
{
"match_phrase": {
"name": "First \"Nickname\" Last"
}
}
]
}
}
name:john (is:enrolled OR Teacher)
{
"bool": {
"must": [
{
"bool": {
"must": [
{
"match": {
"name": {
"query": "john",
"operator": "and"
}
}
}
]
}
},
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"enrolled": true
}
}
]
}
},
{
"bool": {
"must": [
{
"simple_query_string": {
"query": "Teacher"
}
}
]
}
}
]
}
}
]
}
}