Hello, I’m using meteor add matteodem:easy-search for my searches and I’ve run into some customization problems.
I have set up Posts.initEasySearch(‘tags’) to seacrh thru posts with certain tags
1.) I would like to have all posts listed while the input field is empty, now when it’s empty their is no data displayed but when i start typing posts I want they get rendered
2.) I want to get the data from my helper into the search since Im filtering it there thru 'posts': return Posts.find("some filter").
It seems easy search access all documents in the collection and not just the ones i return in my helper.
Do I need to set up publish with these filters or something or there is a way to get the data thru the helper?
{{> esInput index="Posts" placeholder="Search using tags..." allDocsOnEmpty=true }}
2.) If I get you correctly, you want to customize your search query, so that while searching, you don’t return all the Posts-docs in minimongo but only a special selection of them, correct? If so, have a look at the javascript API ( http://matteodem.github.io/meteor-easy-search/docs/javascript-api/ ), you can customize properties to filter you data.
@arunoda I couldn’t get your package to work, I copy-pasted your example, changed the code to match mine collection and filter but the data wouldnt get rendered. Only after I would type something in the input field and then delete it it would appear. But i still couldnt filter it, I probably messed up somewhere but couldn’t find where.
forgot to add the error im getting with easy-search:
Exception from Tracker recompute function: object is not a function
TypeError: object is not a function
Thanks for the help but I don’t know to set it up with easy-search, I’ll give arunoda’s search-source a try now.
A general question for all:
How does this search work anyway, does it make a call to the DB every time I search?
If so, isn’t something like a simple filter faster since I already got all my data displayed and now I just wanna filter it with the keywords thru the desired fields? Similar to ng-repeat in Angular and the filter option.
Found out what the problem was finally. My matchText is an array of strings and I can’t call .replace() on array.
I’ve tried using toString() before .replace() but it doesn’t work. And from what I understood it just basically returns the matched string as bold text (highlighted) and I can live without it but figured maybe you want to look into that.
If i comment out / delete that part it all works.
Now I have trouble getting new data appear when I update my collection. It only appears after some time has passed.
I’ve tried changing keepHistory to a low number and removing it completely but it doesn’t work.
Any idea whats the problem?
edit: actually i have to restart server to get the new data in