如何清除meteorhacks的当前搜索结果:search-source?

时间:2021-09-29 16:40:36

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:

这是我的情景:

  1. User starts typing a valid search term
  2. 用户开始键入有效的搜索词

  3. search-source performs the search and the server returns a number of documents that meet the criteria
  4. search-source执行搜索,服务器返回符合条件的许多文档

  5. User types another character that invalidates the regex
  6. 用户键入另一个使正则表达式无效的字符

  7. I don't want to run the search with an invalid search term
  8. 我不想使用无效的搜索字词来运行搜索

  9. However the search results that I obtained earlier remain visible
  10. 然而,我之前获得的搜索结果仍然可见

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:

做空白搜索为我清除它:

如何清除meteorhacks的当前搜索结果:search-source?

Maybe there's something in your SearchSource.defineSource causing the overflow?

也许你的SearchSource.defineSource中有一些东西导致溢出?

#1


doing a blank search clears it for me:

做空白搜索为我清除它:

如何清除meteorhacks的当前搜索结果:search-source?

Maybe there's something in your SearchSource.defineSource causing the overflow?

也许你的SearchSource.defineSource中有一些东西导致溢出?