I need your expertise on the following situation.
I have a collection as such:
"array" : {
"item" : 1,
"1" : [100, 130, 255],
}
"array" : {
"item" : 2,
"1" " [0, 70, 120],
}
"array" : {
"item" : 3,
"1" : [100, 90, 140],
}
I am querying this collection as such:
db.test.find(array.1 : {$in : [100, 80, 140]});
This returns me item number 1 and 3 since it matches any values in the provided array with the ones in the collection. However I would like to sort this array to give me the results with more similar numbers. The result should be items 3 and 1 respectively.
I can however grab the results and use a k-nearest neighbor algorithm to sort the array. However dealing with huge datasets makes this very undesirable (or is it?) Are there any functions within MongoDB to provide this? I am using Java, any algorithms to achieve this fast enough? Any help is appreciated.
Thanks.