Hi all, new to ElasticSearch and I have made good progress with a number of queries I am looking to execute. However one seems to elude me.
I have the following document structure.
{
"resourceId": 101,
"sourceId": 201,
"sourceTypeId": 301,
"attributeId": 401,
"term": "The cat sat on the mat"
}
There can exist multiple documents with the same resourceId but never a document with the same attributeId and resourceId (my composite key).
I am currently running this query to get me all results that match a sourceTypeId and attributeId (or number of them) and a search term:
{
"size": 20,
"from": 0,
"query" : {
"bool": {
"filter": [ {
"terms": {
"sourceTypeId": [ 1000150 ]
}
}, {
"terms": {
"attributeId": [ 1000697 ]
}
} ],
"must": {
"fuzzy": { "term": "cat" }
}
}
}
}
However I get duplicate resource id's which is to be expected, how would I go about extending this to return only documents with a distinct resourceId?
I am using AWS ElasticSearch so am locked to version 2.3 if that helps.