Reputation: 13
I am trying to combine a range filter query, a bool-must-match query, and a constant score (terms) filter query all in one query. I have both the range filter query and the bool-must-match query combine so far:
{
"query": {
"bool": {
"must": [
{
"match": {
"market": "Android"
}
}
],
"filter": [
{
"range": {
"sold": {
"gte": "20170601",
"lte": "20170602"
}
}
}
]
}
}
}
How do I add this query in there:
{
"query" : {
"constant_score" : {
"filter" : {
"terms" : {
"price" : [200, 300]
}
}
}
}
}
Is there a way to combine all three together?
Upvotes: 0
Views: 97
Reputation: 217254
You can simply add it in the bool/filter
section as filters have a constant score:
{
"query": {
"bool": {
"must": [
{
"match": {
"market": "Android"
}
}
],
"filter": [
{
"terms": {
"price": [
200,
300
]
}
},
{
"range": {
"sold": {
"gte": "20170601",
"lte": "20170602"
}
}
}
]
}
}
}
Upvotes: 0