Reputation: 177
I want to write a complex elastic search query. I know how to write them separately. But don't know how to combine them. I have two fields in doc.(paid(boolean) and money(float)). I want all the docs where paid=false and money>0. This is what I have done.
GET /_search
{
"query": {
"range" : {
"money" : {
"gte" : 0,
"lte" :1000
}
}
}
}
GET /_search
{
"query": {
"term": {
"paid": false
}
}
}
EDIT1
now if I have a nested field I want to search on that as well.
GET /_search
{
"query": {
"nested": {
"path": "sellers_info",
"query": {
"bool": {
"must": [
{
"match": {
"sellers_info.seller_label": "Owner"
}
}
]
}
}
}
}
}
How to combine these three?
Upvotes: 1
Views: 52
Reputation: 217544
Great start! Simply combine them with bool/filter
, like this:
GET /_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"paid": false
}
},
{
"range": {
"money": {
"gte": 0,
"lte": 1000
}
}
}
]
}
}
}
Upvotes: 1