|
11 | 11 | * - Removes ajax call to get context for each result
|
12 | 12 | * - Adjusts Search.query to remove duplicates in search results.
|
13 | 13 | * - Adjusts Scorer to rank objects higher.
|
14 |
| - * - Adds Search._total_results to limit the number of search results. |
| 14 | + * - Adds Search._total_non_object_results to limit the number of search non |
| 15 | + * object results. Object results do not perform another GET resquest, so they |
| 16 | + * are cheap to display. |
15 | 17 | */
|
16 | 18 |
|
17 | 19 | if (!Scorer) {
|
@@ -63,10 +65,10 @@ var Search = {
|
63 | 65 | _index: null,
|
64 | 66 | _queued_query: null,
|
65 | 67 | _pulse_status: -1,
|
66 |
| - _total_results: 10, |
| 68 | + _total_non_object_results: 10, |
67 | 69 |
|
68 | 70 | htmlToText: function (htmlString) {
|
69 |
| - var htmlString = htmlString.replace(/<img.+?>/g, ""); |
| 71 | + var htmlString = htmlString.replace(/<img[\s\S]+?>/g, ""); |
70 | 72 | var htmlElement = document.createElement("span");
|
71 | 73 | htmlElement.innerHTML = htmlString;
|
72 | 74 | $(htmlElement)
|
@@ -218,22 +220,23 @@ var Search = {
|
218 | 220 | objectterms.slice(i + 1, objectterms.length)
|
219 | 221 | );
|
220 | 222 |
|
221 |
| - if (results.length < this._total_results) { |
222 |
| - results = $u.uniq(results.concat( |
223 |
| - this.performObjectSearch(objectterms[i], others) |
224 |
| - ), false, function (item) {return item[1]}); |
225 |
| - } |
| 223 | + results = $u.uniq(results.concat( |
| 224 | + this.performObjectSearch(objectterms[i], others) |
| 225 | + ), false, function (item) {return item[1]}); |
226 | 226 | }
|
227 | 227 |
|
228 |
| - if (results.length < this._total_results) { |
229 |
| - // lookup as search terms in fulltext |
230 |
| - results = results.concat( |
231 |
| - this.performTermsSearch(searchterms, excluded, terms, titleterms) |
232 |
| - ); |
233 |
| - } |
| 228 | + var total_object_results = results.length; |
| 229 | + |
| 230 | + // lookup as search terms in fulltext |
| 231 | + results = results.concat( |
| 232 | + this.performTermsSearch(searchterms, excluded, terms, titleterms) |
| 233 | + ); |
234 | 234 |
|
235 |
| - if (results.length > this._total_results) { |
236 |
| - results = results.slice(0, this._total_results); |
| 235 | + // Only have _total_non_object_results results above the number of |
| 236 | + // total number of object results |
| 237 | + var results_limit = total_object_results + this._total_non_object_results |
| 238 | + if (results.length > results_limit) { |
| 239 | + results = results.slice(0, results_limit); |
237 | 240 | }
|
238 | 241 |
|
239 | 242 | // let the scorer override scores with a custom scoring function
|
|
0 commit comments