TERM
Facets with Multi Fields
The term facet can be executed against more than one
field, returning the aggregation result across those fields.
Here
is an example:
POST
Method:
http://localhost:9200/mobiles/_search?pretty=true
{
"query": {
"query_string": {
"query": "can*"
}
},
"facets": {
"type": {
"terms": {
"fields" : ["_type", "name"]
}
}
}
}
Results:
{
"took": 6,
"timed_out":
false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "mobiles",
"_type": "micromax",
"_id": "2",
"_score": 1,
"_source": {
"name": "canvas"
}
}
]
},
"facets": {
"type": {
"_type": "terms",
"missing": 0,
"total": 2,
"other": 0,
"terms": [
{
"term": "micromax",
"count": 1
},
{
"term": "canvas",
"count": 1
}
]
}
}
}
No comments:
Post a Comment