I need distinct records from elastic search query like we do in database as
select distinct(title) from tablename
instead of
select count(distinct(title)) from tablename
I have used aggregation but it does not solve my problem because it gives only count , i need some search filter or anything else that give me result like this, if i have 3 records:
id title
1 ab is
2 sdf sdf
3 ab is
and then i fetch from query it gives me output as :
hits : [
1 : ab is
2 : sdf sdf
]
query i am applying is
{ "query": {
"match" : {"title" : "sing alongs"}
},
"from": 0,
"aggs": {
"genres": {
"terms": {
"field": "title"
}
}
},
"size": 30,
"_source": [
"title"
]}
and result i am getting is
{
{
"_index": "events",
"_type": "Activity",
"_id": "F-m5MGABRY8M87iCVeBZ",
"_score": 21.652287,
"_source": {
"title": "Sing Alongs"
}
} ,
{
"_index": "events",
"_type": "Activity",
"_id": "6OuBwmABRY8M87iCPxNh",
"_score": 9.333357,
"_source": {
"title": "Sing Along"
}
},
{
"_index": "events",
"_type": "Activity",
"_id": "Q-mEIWABRY8M87iC7Ytl",
"_score": 9.320941,
"_source": {
"title": "Sing-Through"
}
}
}
record with title
sing alongs
should appear only once here