Reputation: 41
I am new to Meteor and am having trouble with the following. I need to implement reactive search with multiple collections and multiple fields/$and selector. Any kind of guidance will be much appreciated.
The app should use the 4/5 collections and then based on 3 text-filters (DB fields) and the collection choice (from a drop down menu), return reactive results.So, let's say, from the drop down , they select collection c1 and then type in the following - for field f1, 11, for field f2, 22, f3, 33.
Now the app should return documents from c1 that have the respective values {f1:11, f2:22...} for the 3 fields.
The query will be something like:
collection.find({$and: [{f1:11, f2:22, f3:33...}]})
What I have been trying so far.
Using autoform, I have developed a form with the drop down and textboxes. I am not sure how to proceed from here - how to integrate, say easy-search with autoform.
Just easy-search. I am still working on developing the reactive search using just this package. I am following the leaderboard example there. Being in dev phase, I don't know what else I will need to know.
Using reactive-table. I have it working with the default filter. The reactive results come out fine. Now I am trying to customize the filter but it's not working. Not sure what I am doing wrong - helpers.js or the template. Or, if I need to integrate something else-like, easy-search, given the complexity of the query.
Please let me know what code parts you need and I'll add it in my edit. (Adding everything would make it too long).
Upvotes: 2
Views: 261
Reputation: 11177
With EasySearch, you can define your own special queries.
EasySearch.createSearchIndex('cars', {
'field' : ['name', 'price'],
'collection' : Cars,
'limit' : 20,
'query' : function (searchString, opts) {
var query = EasySearch.getSearcher(this.use).defaultQuery(this, searchString);
query.$and = query.$and || {};
// do whatever you need with `$and` here
}
});
Upvotes: 1