Meteor轻松搜索分页集成
我正在使用meteor easy search软件包将搜索和分页集成到我的应用程序中: 我让它工作了,索塔。搜索工作就像一个符咒,但是分页是相当麻烦的。我想显示每页25个结果。如果少于25个结果,显然所有这些结果都应该显示在第一页上。如果有70个结果,第一页应该显示25个,第二页25个,第三页20个 目前的情况是,第1页可能是随机空白的,第2页显示8条记录,第3页将显示其余的记录。而且不总是这样。第1页可能显示15条记录,第2页和第3页显示其余记录。此外,我还尝试按日期对结果进行排序,最新的结果首先出现。这也不能正常工作。它似乎适用于结果的第一部分,但在结果结束时,将有一个不合适的随机条目 我有一种感觉,我的实现在某个地方出了问题,导致了这些奇怪而随机的问题。有人能看一下,让我知道我做错了什么吗 在客户端:Meteor轻松搜索分页集成,meteor,Meteor,我正在使用meteor easy search软件包将搜索和分页集成到我的应用程序中: 我让它工作了,索塔。搜索工作就像一个符咒,但是分页是相当麻烦的。我想显示每页25个结果。如果少于25个结果,显然所有这些结果都应该显示在第一页上。如果有70个结果,第一页应该显示25个,第二页25个,第三页20个 目前的情况是,第1页可能是随机空白的,第2页显示8条记录,第3页将显示其余的记录。而且不总是这样。第1页可能显示15条记录,第2页和第3页显示其余记录。此外,我还尝试按日期对结果进行排序,最新的结
Template.history.rendered = function () {
var instance = EasySearch.getComponentInstance(
{ id : 'search', index : 'items' }
);
EasySearch.changeLimit('items', 25);
EasySearch.pagination('items', EasySearch.PAGINATION_NEXT); // Go to the second step
};
在客户端和服务器上:
Items = new Mongo.Collection("items");
EasySearch.createSearchIndex('items', {
'collection': Items,
'field': ["details","createdAt"],
'limit': 10,
'use' : 'mongo-db',
'props': {
'sortBy': 'asc'
},
'sort': function() {
if (this.props.sortBy === 'asc') {
return { 'createdAt': -1 };
}
},
'query': function(searchString, opts) {
var query = EasySearch.getSearcher(this.use).defaultQuery(this, searchString);
return query;
}
});
在历史记录html模板中:
{{> esInput allDocsOnEmpty=true index="items" id="search" placeholder="Search now..." }}
{{> esPagination index="items" id="search" }}
{{#esEach index="items" id="search"}}
{{#if isOwner username }}
<tr style="height: 150px;">
<td>{{ username }}</td>
<td>{{ formatTime createdAt }}</td>
<td> {{ details }} </td>
</tr>
{{/if}}
{{/esEach}}
{{>esInput allDocsOnEmpty=true index=“items”id=“search”placeholder=“search now…”
{{>esPagination index=“items”id=“search”}
{{{#esEach index=“items”id=“search”}
{{#如果是所有者用户名}
{{username}}
{{formatTime createdAt}}
{{详细信息}
{{/if}
{{/esEach}}
我没有确切的解决方案,但我认为您已经定义了两个限制。一个在索引中,另一个在结果中,但我确实认为它们可能冲突?25岁和10岁