elasticsearch - Get count for unique terms -


in elasticsearch, want unique terms , counts terms.

 index: doc1: filetype(multivalued): pdf, zip, zip, txt  expected result: pdf: 1 zip: 2 txt: 1 

i made query, got error.

"aggs": {     "uniqueterms": {         "terms": {             "field": "filetype"         }     },     "aggs": {         "count": {             "cardinality": {                 "field": "filetype"             }         }     } } 

how can make query result?

index mapping updated:

"file" : {     "properties" : {         "filetype" : {             "type" : "string",             "norms" : {                 "enabled" : false             },             "fields" : {                   "raw" : {                       "type" : "string",                       "index" : "not_analyzed",                       "ignore_above" : 256                   }               }           }       } } 

good start, you're there. need nest cardinality aggregation 1 level deeper.

{   "aggs": {     "uniqueterms": {       "terms": {         "field": "filetype"       },       "aggs": {         "count": {           "cardinality": {             "field": "filetype"           }         }       }     }   } } 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -