Skip to content

Instantly share code, notes, and snippets.

@ncolomer
Last active Dec 16, 2015
Embed
What would you like to do?
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