I am trying to figure out how to apply multiple post_filters (like when a user selects multiple facets/aggregations)
"post_filter": {
"bool": {
"must": [
{
"terms": { "category": [ "Jewelry Collections", "Rings" ] }
},
{
"terms": { "size_jewelry": [ "6.5", "7"] }
},
{
"range": { "price": [{ "gte": 0, "lte": 100 },{ "gte": 100, "lte": 200 }] }
}
]
}
}
That obviously doesn't work. Basically, I'm trying to this:
category="Jewelry Collections" OR "Rings"
AND
size_jewelry="6.5" OR "7"
AND
price =0-100 OR price 100-200
Any help appreciated
I * think* I found the answer:
"post_filter": {
"bool": {
"must": [
{
"terms": { "category": [ "Celtic Jewelry Collections", "Solvar Jewelry" ] }
},
{
"terms": { "size_jewelry": [ "6.5" ] }
},
{
"bool": {
"should" : [
{
"range": { "price": { "gte": 0, "lte": 200 } }
},
{
"range": { "price": { "gte": 200, "lte": 400 } }
}
]
}
}
]
}
}
nik9000
(Nik Everett)
November 15, 2016, 5:22pm
3
"post_filter": {
"bool": {
"must": [
{
"terms": { "category": [ "Celtic Jewelry Collections", "Solvar Jewelry" ] }
},
{
"terms": { "size_jewelry": [ "6.5" ] }
}
]
"should" : [
{
"range": { "price": { "gte": 0, "lte": 200 } }
},
{
"range": { "price": { "gte": 200, "lte": 400 } }
}
],
"minimum_should_match": 1
}
}
Ought to work as well. These are the docs for bool
and these are the docs for minimum_should_match
.
that does work too - thanks Nik!
system
(system)
Closed
December 13, 2016, 6:04pm
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.