title: Meteor: Create filters for a collection server side and store them in a local collection. Good idea?
body: <p>We have pretty big sets of documents that we want our users to be able to view and filter. To speed things up we're only sending a limited amount of documents down to the client. However, since we do need the clients to be able to filter the documents we need a way to send down the keys and values they can filter on. Based on the clients selection of filters we create a query for the documents. Say for instance that we have two documents like this:</p>
  
  <p>{tags: ['foo'], user: 'Ken'}
  {tags: ['bar', 'baz'], user: 'Barbie'}</p>
  
  <p>In this case, the client should see that tags can be filtered on foo, bar and baz while user can be filtered on Ken and Barbie. Since the filters are just an aggregation of the data in the documents I dont want to create a collection for the filters and store it in the db. Instead I've been playing around with using </p>
  
  <p>var Filters = new Meteor.Collection(null) </p>
  
  <p>inside a publication. I query all documents I want to create filters for and then I insert the filters to the Filters collection. Using .observe on the Filters collection i send down the filters to the client as they get added.</p>
  
  <p>The result of this is that each client creates a Filters collection on the server. Say that each of those collections contain about 50-400 filters like {tag: 'foo', count: 3}. To me that sounds as if it should be fine without draining the ram of the server, but I'm no computer scientist. Any input on this would be appreciated. </p>
  
  <p>If you have any other ideas of how to create filters on the server would also be interesting to look at.</p>
  
  <p>Thanks!</p>