mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
search performance: Stop at max_items.
Once we have max_items results, stop trying to get more items. This should really help large realms when you do a search on streams that turns up more than N streams (where N is about 12). We won't even bother to find people.
This commit is contained in:
@@ -85,9 +85,11 @@ run_test('initizalize', () => {
|
||||
return 'is:starred';
|
||||
};
|
||||
|
||||
search_suggestion.max_num_of_search_results = 99;
|
||||
search_query_box.typeahead = (opts) => {
|
||||
|
||||
assert.equal(opts.fixed, true);
|
||||
assert.equal(opts.items, 12);
|
||||
assert.equal(opts.items, 99);
|
||||
assert.equal(opts.naturalSearch, true);
|
||||
assert.equal(opts.helpOnEmptyStrings, true);
|
||||
assert.equal(opts.matcher(), true);
|
||||
|
||||
@@ -63,9 +63,10 @@ run_test('initialize', () => {
|
||||
assert(search.is_using_input_method);
|
||||
};
|
||||
|
||||
search_suggestion.max_num_of_search_results = 999;
|
||||
search_query_box.typeahead = (opts) => {
|
||||
assert.equal(opts.fixed, true);
|
||||
assert.equal(opts.items, 12);
|
||||
assert.equal(opts.items, 999);
|
||||
assert.equal(opts.naturalSearch, true);
|
||||
assert.equal(opts.helpOnEmptyStrings, true);
|
||||
assert.equal(opts.matcher(), true);
|
||||
|
||||
@@ -13,6 +13,8 @@ zrequire('unread');
|
||||
zrequire('common');
|
||||
const search = zrequire('search_suggestion');
|
||||
|
||||
search.max_num_of_search_results = 15;
|
||||
|
||||
const bob = {
|
||||
email: 'bob@zulip.com',
|
||||
full_name: 'Bob Roberts',
|
||||
|
||||
@@ -99,6 +99,7 @@ zrequire('upload');
|
||||
zrequire('compose');
|
||||
zrequire('composebox_typeahead');
|
||||
zrequire('narrow');
|
||||
zrequire('search_suggestion');
|
||||
zrequire('search');
|
||||
zrequire('tutorial');
|
||||
zrequire('notifications');
|
||||
|
||||
@@ -81,7 +81,7 @@ exports.initialize = function () {
|
||||
return suggestions.strings;
|
||||
},
|
||||
fixed: true,
|
||||
items: 12,
|
||||
items: search_suggestion.max_num_of_search_results,
|
||||
helpOnEmptyStrings: true,
|
||||
naturalSearch: true,
|
||||
highlighter: function (item) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
exports.max_num_of_search_results = 12;
|
||||
|
||||
function stream_matches_query(stream_name, q) {
|
||||
return common.phrase_match(q, stream_name);
|
||||
}
|
||||
@@ -779,14 +781,21 @@ exports.get_search_result_legacy = function (query) {
|
||||
get_has_filter_suggestions,
|
||||
];
|
||||
|
||||
const max_items = exports.max_num_of_search_results;
|
||||
|
||||
_.each(filterers, function (filterer) {
|
||||
if (attacher.result.length < max_items) {
|
||||
const suggestions = filterer(last, base_operators);
|
||||
attacher.attach_many(suggestions);
|
||||
}
|
||||
});
|
||||
|
||||
if (attacher.result.length < max_items) {
|
||||
const subset_suggestions = get_operator_subset_suggestions(operators);
|
||||
attacher.concat(subset_suggestions);
|
||||
return attacher.result;
|
||||
}
|
||||
|
||||
return attacher.result.slice(0, max_items);
|
||||
};
|
||||
|
||||
exports.get_suggestions_legacy = function (query) {
|
||||
|
||||
Reference in New Issue
Block a user