Hi rookie1.
Yes, you can group data by multiple fields. One difference from SQL is that that results can be a tree structure with hierarchy rather than thinking of them like a flattened table of results.
You would use the terms aggregation to group information. For example, given an index of investment data field1 might be investor and field 2 might be the company invested in:
GET /crunchbase/_search
{
"size":0,
"aggregations": {
"first_by_investor": {
"terms": {
"field": "investor"
},
"aggregations": {
"then_by_company": {
"terms": {
"field": "company"
}
}
}
}
}
}
The results are a hierarchy like this (default sort size is by number of docs):
...
"aggregations" : {
"first_by_investor" : {
"buckets" : [
{
"key" : "New Enterprise Associates",
"doc_count" : 445,
"then_by_company" : {
"buckets" : [
{
"key" : "PatientKeeper",
"doc_count" : 5
},
{
"key" : "SolFocus",
"doc_count" : 5
}
...
},
{
"key" : "SV Angel",
"doc_count" : 436,
...
}
]