elasticsearch get statistics on analyzed field -
i trying statistics on analyzed string field.
i trying avg length of string field (in example title, , title can empty/none).
tried:
get book/_search { "facets" : { "stat1" : { "statistical" : { "script" : "_source.title?.length()" } } } }
and error:
query failed [failed execute main query]]; nested: nullpointerexception; }]", "status": 500 }
how can accomplish that?
any reason why using facets
, not aggregations? unless use elasticsearch version supports facets, recommend switching aggregations. facets deprecated in 1.x , removed in 2.x.
and aggregation 1 should work fine:
get /book/_search { "aggs": { "stat1": { "stats": { "script": "_source.title?.length() ?: 0" } } } }
Comments
Post a Comment