[英]aggs filter is not working in elastic searach
I am working On Elastic Search For My Current Project.. Need to Remove Duplicate Records My O/p Is as follows: 我正在为我当前的项目进行弹性搜索。需要删除重复的记录,我的O / p如下:
array (
数组(
[1] => Array
(
[_index] => vendors
[_type] => practiceareas
[_id] => 582
[_score] =>
[_source] => Array
(
[practice_area_id] => 364
[id] => 582
[practice_area_name] => Joint Pains
[industry_id] => 9
[category_id] => 12
)
)
[2] => Array
(
[_index] => vendors
[_type] => practiceareas
[_id] => 1315
[_score] =>
[_source] => Array
(
[practice_area_id] => 237
[id] => 1315
[practice_area_name] => Anemia
[industry_id] => 9
[category_id] => 15
)
)
[3] => Array
(
[_index] => vendors
[_type] => practiceareas
[_id] => 2087
[_score] =>
[_source] => Array
(
[practice_area_id] => 364
[id] => 2087
[practice_area_name] => Joint Pains
[industry_id] => 2
[category_id] => 12
)
)
[4] => Array
(
[_index] => vendors
[_type] => practiceareas
[_id] => 2820
[_score] =>
[_source] => Array
(
[practice_area_id] => 237
[id] => 2820
[practice_area_name] => Anemia
[industry_id] => 2
[category_id] => 15
)
)
[5] => Array
(
[_index] => vendors
[_type] => practiceareas
[_id] => 5312
[_score] =>
[_source] => Array
(
[practice_area_id] => 364
[id] => 5312
[practice_area_name] => Joint Pains
[industry_id] => 2
[category_id] => 28
)
)
) )
I need to eliminate replicate values by using practice_area_id / practice_area_name 我需要通过使用Practice_area_id / Practice_area_name消除重复值
I already tired as per references.. and my code is as follows: 根据参考,我已经很累了。我的代码如下:
$query = array(
"from" => $from,
"size" => $size,
"sort" => array(array($fieldname => 'desc')),
"query" => array(
"filtered" => array(
"query" => array("match_all" => array())
)
),
"aggs" => array(
"distinct" => array(
"terms" => array(
"field" => "practice_area_name",
)
)
)
);
But it is not working.. please help me with a solution. 但是它不起作用..请帮助我提供解决方案。 Thanks in Advance.
提前致谢。
you want to remove replicate documents or you just want to check total distinct documents by practice_area_name or practice_area_id ? 您要删除重复文档,还是只想按Practice_area_name或Practice_area_id检查不同的文档总数?
For the second question the sense query look like this
对于第二个问题,意义查询看起来像这样
POST vendors/practiceareas/_search
{
"size": 0,
"query": {
"match_all": {}
},
"aggs":{
"distinct-values":{
"terms":{
"field":"practice_area_id",
"min_doc_count":2
}
}
}
}
output look like this
输出看起来像这样
"aggregations": {
"distinct-values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 364,
"doc_count": 3
},
{
"key": 237,
"doc_count": 2
}
]
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.