1
0
mirror of https://github.com/flarum/core.git synced 2025-07-29 20:50:28 +02:00

Improve fulltext search API and interface

This commit is contained in:
Toby Zerner
2015-07-07 20:35:18 +09:30
parent 38c2ff0306
commit 42f1fa1272
12 changed files with 62 additions and 81 deletions

View File

@@ -23,7 +23,10 @@ export default class DiscussionList extends Component {
}
params.sort = this.sortMap()[params.sort];
if (params.q) {
params.filter = params.filter || {};
params.filter.q = params.q;
params.include.push('relevantPosts', 'relevantPosts.discussion', 'relevantPosts.user');
delete params.q;
}
return params;
}

View File

@@ -9,7 +9,7 @@ export default class DiscussionsSearchResults {
search(string) {
this.results[string] = [];
return app.store.find('discussions', {filter: {q: string}, page: {limit: 3}, include: 'relevantPosts,relevantPosts.discussion'}).then(results => {
return app.store.find('discussions', {filter: {q: string}, page: {limit: 3}, include: 'relevantPosts,relevantPosts.discussion,relevantPosts.user'}).then(results => {
this.results[string] = results;
});
}

View File

@@ -5,7 +5,7 @@ export default function(string, phrase, length) {
return string;
}
const regexp = regexp instanceof RegExp ? phrase : new RegExp(phrase, 'gi');
const regexp = phrase instanceof RegExp ? phrase : new RegExp(phrase, 'gi');
let highlightedString = string;
let start = 0;