TERM
Facets with Ordering
Allow to control the ordering of the terms facets,
to be ordered by count, term, reverse_count or reverse_term. The default is
count.
Here
is an example:
POST
Method:
http://localhost:9200/mobiles/_search?pretty=true
{
"query": {
"query_string": {
"query": "*a*"
}
},
"facets": {
"type": {
"terms": {
"field": "_type",
"order" : "term",
"all_terms": true
}
}
}
}
Results:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful":
1,
"failed": 0
},
"hits": {
"total": 5,
"max_score": 1,
"hits": [
{
"_index": "mobiles",
"_type": "nokia",
"_id": "1",
"_score": 1,
"_source": {
"name": "lumia 510"
}
},
{
"_index": "mobiles",
"_type": "nokia",
"_id": "2",
"_score": 1,
"_source": {
"name": "lumia 520"
}
},
{
"_index": "mobiles",
"_type": "nokia",
"_id": "3",
"_score": 1,
"_source": {
"name": "lumia 625"
}
},
{
"_index": "mobiles",
"_type": "nokia",
"_id": "4",
"_score": 1,
"_source": {
"name": "lumia 720"
}
},
{
"_index": "mobiles",
"_type": "micromax",
"_id": "2",
"_score": 1,
"_source": {
"name": "canvas"
}
}
]
},
"facets": {
"type":
{
"_type": "terms",
"missing": 0,
"total": 5,
"other": 0,
"terms": [
{
"term": "micromax",
"count": 1
},
{
"term": "nokia",
"count": 4
},
{
"term": "samsung",
"count": 0
}
]
}
}
}
No comments:
Post a Comment