Uczę się elastycznego wyszukiwania i chciałbym policzyć różne wartości. Do tej pory mogę policzyć wartości, ale nie odrębne.Oblicz różne wartości za pomocą elasticsearch
Oto przykładowe dane:
curl http://localhost:9200/store/item/ -XPOST -d '{
"RestaurantId": 2,
"RestaurantName": "Restaurant Brian",
"DateTime": "2013-08-16T15:13:47.4833748+01:00"
}'
curl http://localhost:9200/store/item/ -XPOST -d '{
"RestaurantId": 1,
"RestaurantName": "Restaurant Cecil",
"DateTime": "2013-08-16T15:13:47.4833748+01:00"
}'
curl http://localhost:9200/store/item/ -XPOST -d '{
"RestaurantId": 1,
"RestaurantName": "Restaurant Cecil",
"DateTime": "2013-08-16T15:13:47.4833748+01:00"
}'
A co starałem dotąd:
curl -XPOST "http://localhost:9200/store/item/_search" -d '{
"size": 0,
"aggs": {
"item": {
"terms": {
"field": "RestaurantName"
}
}
}
}'
wyjściowa:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 0.0,
"hits": []
},
"aggregations": {
"item": {
"buckets": [
{
"key": "restaurant",
"doc_count": 3
},
{
"key": "cecil",
"doc_count": 2
},
{
"key": "brian",
"doc_count": 1
}
]
}
}
}
Jak mogę uzyskać liczbę cecil
jako 1 zamiast z 2
Próbowałem nawet: curl -XPOST "http: // localhost: 9200/store/item/_search" -d '{"size": 0, "aggs": {"item": {"cardinality": { "field": "RestaurantName"}}}} ', ale nie otrzymuje wyraźnych liczb – Developer
Powinien być zwinięty -XGET? – c24b
i czy można zmienić nazwę agregatu jako przedmiotu? – c24b