Hello,
I am trying to get distinct count form the elastic search. for the grouping I am using cardinality aggregation along with query string.
I am using elastic 6.x with php client.
below is my query.
Array
(
[index] => o_contacts.o_contacts_profile
[body] => Array
(
[query] => Array
(
[bool] => Array
(
[must] => Array
(
[0] => Array
(
[term] => Array
(
[status_flag] => g
)
)
[1] => Array
(
[terms] => Array
(
[contact_id] => Array
(
[0] => 5
[1] => 8
[2] => 1
[3] => 4
[4] => 2
[5] => 7
)
)
)
[2] => Array
(
[match] => Array
(
[status] => 1
)
)
[3] => Array
(
[match] => Array
(
[white_list_flag] => 1
)
)
[4] => Array
(
[match] => Array
(
[bounce_flag] => 1
)
)
[5] => Array
(
[0] => Array
(
[range] => Array
(
[age] => Array
(
[gte] => 0
[lte] => 95
)
)
)
[1] => Array
(
[range] => Array
(
[delivery_timestamp] => Array
(
[gte] => 0
)
)
)
)
[6] => Array
(
[terms] => Array
(
[gender] => Array
(
[1] => Male
[2] => Female
[3] => Unspecified
)
)
)
[7] => Array
(
[terms] => Array
(
[loc] => Array
(
[0] => England
)
)
)
[8] => Array
(
[terms] => Array
(
[town] => Array
(
[0] => Cambridge
)
)
)
[9] => Array
(
[terms] => Array
(
[region] => Array
(
[0] => East
)
)
)
)
[must_not] => Array
(
[0] => Array
(
[term] => Array
(
[sunset_flag] => 1
)
)
[1] => Array
(
[term] => Array
(
[global_flag] => 1
)
)
[2] => Array
(
[term] => Array
(
[flag] => 1
)
)
[3] => Array
(
[terms] => Array
(
[contact_email_id] => Array
(
)
)
)
[4] => Array
(
[terms] => Array
(
[email_domain_id] => Array
(
[0] => 100
)
)
)
)
)
)
[aggs] => Array
(
[count] => Array
(
[cardinality] => Array
(
[field] => contact_email_id
[precision_threshold] => 10000
)
)
)
)
[size] => 0
)
I have bulk collection. When ever I am trying to get unique data from the elastic it is showing greater count than the available.
i.e
[aggregations] => Array
(
[count] => Array
(
[value] => 55882
)
)
but the expected count is 52500. (In order to complete the task the count should be equal)
Kindly let me know is there any other way to solve this issue.