Reputation: 2665
I have an sql query like
select student_name,roll_number
from
mytable
where
(course = 'CCNA' or course = 'MCSE') and course NOT Like '%network%'
How can i create an equivalent nested boolean query
in elasticsearch
?
Upvotes: 0
Views: 66
Reputation: 1273
Below query might help you, This query responds with records which course does not contain a "network" keyword and course has a value "ccna" or "mcse". I have not considered a case sensitiveness feature here and assumed that you have a default mapping.
POST study-doc*/_search
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"term": {
"course": {
"value": "ccna"
}
}
},{
"term": {
"course": {
"value": "msce"
}
}
}
]
}},
{
"bool": {
"must": [
{
"wildcard": {
"course.keyword": {
"value": "^((?!network).)*$"
}
}
}
]
}
}
]
}
}
}
Upvotes: 2