I am trying to write the below mentioned SQL query using elasticsearch query DSL, but i am not able to get the same result as the SQL query. Can anyone help e with the bool query for the below mentioned case. I am using elasticsearch 2.1.1 version.
id.eq(someId)
.and(
(anotherId.eq(another).and(node.eq(node)))
.or
(domain.in(List))
)
This is what i tried. If this is correct how do i write the same query in Java DSL?
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"id": 1
}
}
]
}
},
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"anotherId": "ss"
}
},
{
"term": {
"node": "ss"
}
}
]
}
},
{
"bool": {
"must": [
{
"terms": {
"domain" : [ "cc", "cc" ]
}
}
]
}
}
]
}
}
}
}
}
This is the correct way of doing it in ES 2.1.1
{
"query": {
"bool": {
"filter": [
{
"term": {
"id": 1
}
},
{
"bool": {
"should": [
{
"bool": {
"filter": [
{
"term": {
"anotherId": "ss"
}
},
{
"term": {
"node": "ss"
}
}
]
}
},
{
"terms": {
"domain": [
"cc",
"cc"
]
}
}
]
}
}
]
}
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments