Closed pwjbj closed 3 years ago
in php cannot work
We support aggregation as reported in your json example. You need to pass the terms
as associative array [ 'field' => 'name']
and not as regular array. The full example is as follows:
$params['aggs'] = [
'popular_colors' => [
'terms' => [
'field' => 'name'
]
]
];
@endorama are you sure, I got this kind of error
Elasticsearch\Common\Exceptions\UnexpectedValueException "aggs" is not a valid parameter. Allowed parameters are "_source", "_source_excludes", "_source_includes", "allow_no_indices", "allow_partial_search_results", "analyze_wildcard", "analyzer", "batched_reduce_size", "ccs_minimize_roundtrips", "default_operator", "df", "docvalue_fields", "error_trace", "expand_wildcards", "explain", "filter_path", "from", "human", "ignore_throttled", "ignore_unavailable", "lenient", "max_concurrent_shard_requests", "min_compatible_shard_node", "opaqueId", "pre_filter_shard_size", "preference", "pretty", "q", "request_cache", "rest_total_hits_as_int", "routing", "scroll", "search_type", "seq_no_primary_term", "size", "sort", "source", "stats", "stored_fields", "suggest_field", "suggest_mode", "suggest_size", "suggest_text", "terminate_after", "timeout", "track_scores", "track_total_hits", "typed_keys", "version"
Additionally, I cannot see aggs in the params white list.
Snippet of code:
$params = [
'size' => 0,
'aggs' => [
'region' => [
'terms' => [
'field' => 'region.keyword'
]
]
]
];
$this->elasticsearchClient->search($params);
Version:
"name": "elasticsearch/elasticsearch",
"version": "v7.16.0",
EDIT: missing body, correct $params
$params = [
'size' => 0,
'body' => [
'aggs' => [
'region' => [
'terms' => [
'field' => 'region.keyword'
]
]
]
]
];