Meteor-angular autocomplete from huge data


#1

I have angular-meteor app that need Material md-autocomplete from collection with 53,296 data with angularUtils.directives.dirPagination but this ammount of data make my browser hang I publish collection on server side with some expresion :

Meteor.publish('city', function (options, searchString) {
var where = {
'city_name': {
'$regex': '.*' + (searchString || '') + '.*' ,
'$options': 'i'
}
};
return City.find(where, options);
});

I subscribe on route :

subscriptions: function () {
Meteor.subscribe('city');
this.register('city', Meteor.subscribe('city'));
}

and have pagination on controller :

$scope.currentPage = 1;
$scope.pageSize = 100;
$scope.sort = {city_name_sort : 1};
$scope.orderProperty = '1';
$scope.helpers({
city: function(){
return City.find({});
}

but its take long time to load and its make chrome stop working

if any comments will help so much


#2

Put a limit of 10 or something on it. People aren’t going to scroll through such a long list anyway. You could also wait to subscribe until the user has entered at least two characters. You need to pass the search query through the subscription so that the server sends the right things.

Also, it might be better to make it as a method call instead of subscription, since the cities aren’t going to be changing while the user is searching. Less heavy on the server.


#3

You’re understanding of the technology isn’t sufficient enough to make a practical application.

What does that mean?

Yeah you can brute force it, that’s what you’re doing now. But you won’t get SUPER good results. Take a look at the way Nuance Natural Language does their word prediction. It works on a heirachacle data structure, which uses AI and machine learning to guess at what’s next. It looks easy. It is one of the most complicated technologies in all of time.

What you’re doing now is probably the best way YOU can reproduce it. You’ll have to find ways to cache data in to HTML files for quick processing, maybe, and gain some CPU cycles there.

Good luck,