Created
May 15, 2017 11:23
-
-
Save byronvoorbach/cd9cdf2bbcbede1684201468906ef117 to your computer and use it in GitHub Desktop.
ES 5.4 - Field Collapsing + inner hits throws exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Example gist, showing a possible bug in inner_hits workings in collapse feature when size > amount of results. | |
DELETE webshop | |
#Create some products | |
POST webshop/product/1 | |
{ | |
"title": "The Division - PS4", | |
"family_id": 1 | |
} | |
POST webshop/product/2 | |
{ | |
"title": "The Division - XBOX One", | |
"family_id": 1 | |
} | |
POST webshop/product/3 | |
{ | |
"title": "World of Warcraft", | |
"family_id": 2 | |
} | |
#This query works as expected, just a simple collapse | |
GET webshop/_search | |
{ | |
"from": 0, | |
"size": 20, | |
"query": { | |
"match": { | |
"title": "The Division" | |
} | |
}, | |
"collapse": { | |
"field": "family_id" | |
} | |
} | |
#This query works as expected, just a simple collapse with inner_hits, requesting more products than are available. Empty results responded | |
GET webshop/_search | |
{ | |
"from": 5, | |
"size": 20, | |
"query": { | |
"match": { | |
"title": "The Division" | |
} | |
}, | |
"collapse": { | |
"field": "family_id" | |
} | |
} | |
#This query works as expected, just a simple collapse including inner_hits | |
GET webshop/_search | |
{ | |
"from": 0, | |
"size": 20, | |
"query": { | |
"match": { | |
"title": "The Division" | |
} | |
}, | |
"collapse": { | |
"field": "family_id", | |
"inner_hits" : { | |
"name" : "rollup_hits" | |
} | |
} | |
} | |
#FAILS - The same collapse as before, with inner_hits but now size in query is more than amount of documents returned by query. | |
GET webshop/_search | |
{ | |
"from": 5, | |
"size": 20, | |
"query": { | |
"match": { | |
"title": "The Division" | |
} | |
}, | |
"collapse": { | |
"field": "family_id", | |
"inner_hits" : { | |
"name" : "rollup_hits" | |
} | |
} | |
} | |
#RESULT: | |
{ | |
"error": { | |
"root_cause": [ | |
{ | |
"type": "remote_transport_exception", | |
"reason": "[Byron][127.0.0.1:9300][indices:data/read/msearch]" | |
} | |
], | |
"type": "action_request_validation_exception", | |
"reason": "Validation Failed: 1: no requests added;" | |
}, | |
"status": 400 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment