Group by condition specify type

I'm trying to aggregation tag by specify type such type = 1 and type =2 . But it's not working ???
curl -XDELETE 'localhost:9200/employ'
curl -XPUT 'localhost:9200/employ?pretty' -H 'Content-Type: application/json' -d'
{
"mappings": {
"info": {
"properties": {
"name": { "type": "text", "fielddata": true},
"age": { "type": "text", "fielddata": true},
"tag": {
"properties" : {
"attribute" : {"type" : "text", "fielddata": true},
"type" : {"type" : "text", "fielddata": true}
}
}
}
}
}
}
'
curl -XPUT 'localhost:9200/employ/info/1?refresh&pretty' -H 'Content-Type: application/json' -d'
{
"name": "hungokata",
"age" : 20,
"tag": [
{
"attribute" : 1,
"type": 1
},
{
"attribute": 2,
"type":2
},
{
"attribute": 3,
"type":2
}
]
}
'

curl -XPUT 'localhost:9200/employ/info/2?refresh&pretty' -H 'Content-Type: application/json' -d'
{
"name": "hungokata 123",
"age" : 21,
"tag": [
{
"attribute": 1,
"type": 1
},
{
"attribute": 2,
"type": 2
}
]
}
'

curl -XPUT 'localhost:9200/employ/info/3?refresh&pretty' -H 'Content-Type: application/json' -d'
{
"name": "hungokata",
"age" : 22,
"tag": [
{
"attribute" : 1,
"type": 1
},
{
"attribute" : 2,
"type": 2
}
]
}
'

=>>> Expect But It's not working

curl -XGET 'localhost:9200/employ/_search?pretty' -H 'Content-Type: application/json' -d'
{
"size":0,
"aggs": {
"groupby_attribute_1": {
"filter" : {
"term" : {
"tag.type" : "1"
}
},
"aggs": {
"terms": {
"field": "tag.attribute"
}
}
},
"groupby_attribute_2": {
"filter" : {
"term" : {
"tag.type" : "2"
}
},
"aggs": {
"terms": {
"field": "tag.attribute"
}
}
}
}
}'

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.