Skip to content

Instantly share code, notes, and snippets.

@ncolomer
Last active December 16, 2015 14:19
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 ncolomer/a58042b363f2efdc5f88 to your computer and use it in GitHub Desktop.
Save ncolomer/a58042b363f2efdc5f88 to your computer and use it in GitHub Desktop.
Product/price nested query
{
"size": 16,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"nested": {
"path": "prices",
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"range": {
"price": {
"lte": 100
}
}
}
}
}
}
}
}
},
"partial_fields": {
"partial1": {
"exclude": "prices.*"
}
},
"sort": [
{
"prices.priceSort": {
"order": "asc",
"mode": "min",
"nested_filter": {
"range": {
"price": {
"lte": 100
}
}
}
}
}
],
"facets": {
"priceStats": {
"statistical": {
"field": "price"
},
"facet_filter": {
"range": {
"price": {
"lte": 100
}
}
},
"nested": "prices"
}
}
}
{
"size": 16,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"nested": {
"path": "prices",
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"term": {
"categoryId": 18
}
}
}
}
}
}
}
},
"partial_fields": {
"partial1": {
"exclude": "prices.*"
}
},
"sort": [
{
"prices.priceSort": {
"order": "asc",
"mode": "min",
"nested_filter": {
"term": {
"categoryId": 18
}
}
}
}
],
"facets": {
"priceStats": {
"statistical": {
"field": "price"
},
"facet_filter": {
"term": {
"categoryId": 18
}
},
"nested": "prices"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment