Error : [nested] query does not support [filter]
Code :
GET /_search
{
"query": {
"nested": {
"path": "comments",
"filter": {
"range": {
"comments.date": {
"gte": "2014-10-01",
"lt": "2014-11-01"
}
}
}
}
},
"sort": {
"comments.stars": {
"order": "asc",
"mode": "min",
"nested_filter": {
"range": {
"comments.date": {
"gte": "2014-10-01",
"lt": "2014-11-01"
}
}
}
}
}
}
Detailed Error:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[nested] query does not support [filter]",
"line": 5,
"col": 17
}
],
"type": "parsing_exception",
"reason": "[nested] query does not support [filter]",
"line": 5,
"col": 17
},
"status": 400
}
1 Like
dadoonet
(David Pilato)
October 8, 2017, 8:07am
2
Probably use a bool query with a filter clause instead of filter?
Mapping :
{
"my_index": {
"mappings": {
"blogpost": {
"properties": {
"body": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"comments": {
"type": "nested",
"properties": {
"age": {
"type": "short"
},
"comment": {
"type": "text"
},
"date": {
"type": "date"
},
"name": {
"type": "text"
},
"stars": {
"type": "short"
}
}
},
"tags": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
Updated Code :
GET /_search
{
"query": {
"nested": {
"path": "comments",
"bool" : {
"must" : [
{
"match" : {
"range" : {
"comments.date": {
"gte": "2014-10-01",
"lt": "2014-11-01" }
}
}
}
]
}
}
},
"sort": {
"comments.stars": {
"order": "asc",
"mode": "min",
"nested_filter": {
"range": {
"comments.date": {
"gte": "2014-10-01",
"lt": "2014-11-01"
}
}
}
}
}
}
}
Updated Error :
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[nested] query does not support [bool]",
"line": 5,
"col": 16
}
],
"type": "parsing_exception",
"reason": "[nested] query does not support [bool]",
"line": 5,
"col": 16
},
"status": 400
}
dadoonet
(David Pilato)
October 8, 2017, 9:01am
4
1 Like
Thankyou @dadoonet this worked
system
(system)
Closed
November 5, 2017, 9:18am
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.