There is an index alias that includes two indexes, and the index structure is as follows:
{
"scientific_data_group1": {
"aliases": {
"scientific_data_group": {}
},
"mappings": {
"properties": {
"category_id": {
"type": "keyword"
},
"category_name": {
"type": "keyword"
},
"id": {
"type": "keyword"
},
"patient_id": {
"type": "keyword"
}
}
}
},
"scientific_data_group_nested_20230525144327776": {
"aliases": {
"scientific_data_group": {}
},
"mappings": {
"properties": {
"category_id": {
"type": "keyword"
},
"category_name": {
"type": "keyword"
},
"id": {
"type": "keyword"
}
"patient_id": {
"type": "keyword"
}
}
}
}
}
Now, when using SQL syntax to query, the result of count(distinct patient_id) is larger than count(patient_id). What could be the possible reason for this?
POST _sql?format=json
{
"query": """
SELECT count(patient_id),count(distinct patient_id),category_id FROM scientific_data_group
group by category_id
"""
}