I'm using meteorhacks:search-source to perform server side searches inside a collection.
我正在使用meteorhacks:search-source在集合中执行服务器端搜索。
In my use case only certain regexes are allowed as search terms.
在我的用例中,只允许某些正则表达式作为搜索词。
Here's my scenario:
这是我的情景:
- User starts typing a valid search term
- search-source performs the search and the server returns a number of documents that meet the criteria
- User types another character that invalidates the regex
- I don't want to run the search with an invalid search term
- However the search results that I obtained earlier remain visible
用户开始键入有效的搜索词
search-source执行搜索,服务器返回符合条件的许多文档
用户键入另一个使正则表达式无效的字符
我不想使用无效的搜索字词来运行搜索
然而,我之前获得的搜索结果仍然可见
I've tried running a known query that is guaranteed to return no results however then I end up exceeding Meteor's maximum call stack size. (Literally a stack overflow)
我已经尝试运行一个已知的查询,保证不返回任何结果然后我最终超过Meteor的最大调用堆栈大小。 (字面意思是堆栈溢出)
I see that I can clear the history of the search with .cleanHistory() but that doesn't clear the search results.
我看到我可以使用.cleanHistory()清除搜索的历史记录,但这并不能清除搜索结果。
Sample Code:
Template.foo.events({
'input #myfield': _.throttle(function(ev){
var str = $('#myfield').val();
if ( /[0-9]/.test(str) ) FooSearch.search(str); // FooSearch is a SearchSource object
// else I want no results shown but I want to avoid a server roundtrip
},200)
});
1 个解决方案
#1
doing a blank search clears it for me:
做空白搜索为我清除它:
Maybe there's something in your SearchSource.defineSource
causing the overflow?
也许你的SearchSource.defineSource中有一些东西导致溢出?
#1
doing a blank search clears it for me:
做空白搜索为我清除它:
Maybe there's something in your SearchSource.defineSource
causing the overflow?
也许你的SearchSource.defineSource中有一些东西导致溢出?