'Post_filter on nested type raises elastic error
My index mapping: https://pastebin.com/eBPKXufH
The query:
{
"query": {
"bool": {
"filter": [
[
{
"nested": {
"path": "categories",
"query": {
"match": {
"categories.cats": "360"
}
}
}
}
]
]
}
},
"sort": {
"sale": {
"order": "desc"
}
},
"post_filter": [
{
"nested": {
"path": "64",
"filter": {
"match": {
"64.value": "207"
}
}
}
}
]
}
The error I get is:
{
"error": {
"root_cause": [
{
"type": "x_content_parse_exception",
"reason": "[1:29] [bool] failed to parse field [filter]"
}
],
"type": "x_content_parse_exception",
"reason": "[1:29] [bool] failed to parse field [filter]",
"caused_by": {
"type": "illegal_state_exception",
"reason": "expected value but got [START_ARRAY]"
}
},
"status": 400
}
What I try to accomplish is filter by nested value of categories.cats which is constant query and then post_filter it by nested value of object 64 etc, which is filter criteria but I also need all other values in aggregations (did not post the aggregation query, since it is not relevant I think)
Solution 1:[1]
You have too many square brackets:
"bool": {
"filter": [
[ <--- remove this and the closing one
{
should be
"bool": {
"filter": [
{
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Val |
