Skip to content

Instantly share code, notes, and snippets.

@byronvoorbach
Last active April 12, 2017 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byronvoorbach/bc3d73c77aaa7ddaa96ee47a9ba886fc to your computer and use it in GitHub Desktop.
Save byronvoorbach/bc3d73c77aaa7ddaa96ee47a9ba886fc to your computer and use it in GitHub Desktop.
DELETE test
#Create index
PUT test
{
"mappings": {
"test": {
"properties": {
"colour": {
"type": "keyword"
}
}
}
}
}
#Add document 1
POST test/test/1
{
"title": "this is a test",
"colour": "blue"
}
#Add document 2
POST test/test/2
{
"title": "this is another test",
"colour": "blue"
}
#Query with collapse on colour field, source filtering both on top level document and on inner hits of collapse
#Throws an exception on the inner hits source filtering
#"reason": "[inner_hits] _source doesn't support values of type: START_ARRAY"
GET test/_search
{
"_source": "title",
"query": {
"match_all": {}
},
"collapse": {
"field": "colour",
"inner_hits": {
"name": "collapse",
"_source": [
"title"
]
}
}
}
#Query with collapse on colour field, source filtering both on top level document and on inner hits of collapse
#Throws an exception on the inner hits source filtering
#"reason": "[inner_hits] _source doesn't support values of type: VALUE_STRING"
GET test/_search
{
"_source": "title",
"query": {
"match_all": {}
},
"collapse": {
"field": "colour",
"inner_hits": {
"name": "collapse",
"_source": "title"
}
}
}
#Query with collapse on colour field, source filtering both on top level document and on inner hits of collapse
#This works
GET test/_search
{
"_source": "title",
"query": {
"match_all": {}
},
"collapse": {
"field": "colour",
"inner_hits": {
"name": "collapse",
"_source": {
"includes": ["title"]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment