From 4f8ad70d60137a6558aa84f06e3abc80340243b0 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Wed, 28 Sep 2016 11:03:41 -0700 Subject: [PATCH] fix(search): Update local search syntax to include more results Add prefix search. Previously, if searching for a thread with a specific subject, you had to type the entire subject. Searching for just a prefix wouldn't return the result. This should not affect any of the current search results, only add more results --- .../composer/lib/composer-view.jsx | 2 +- .../lib/search-index-store.es6 | 27 +++++++++---------- src/flux/attributes/matcher.es6 | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/internal_packages/composer/lib/composer-view.jsx b/internal_packages/composer/lib/composer-view.jsx index f5259ef9e..58b38d12c 100644 --- a/internal_packages/composer/lib/composer-view.jsx +++ b/internal_packages/composer/lib/composer-view.jsx @@ -518,7 +518,7 @@ export default class ComposerView extends React.Component { } _onFileReceived = (filePath) => { - // called from onDrop and onPaste - assume images should be inline + // called from onDrop and onFilePaste - assume images should be inline Actions.addAttachment({ filePath: filePath, messageClientId: this.props.draft.clientId, diff --git a/internal_packages/thread-search-index/lib/search-index-store.es6 b/internal_packages/thread-search-index/lib/search-index-store.es6 index 2d7bb9681..eb7e8c4bb 100644 --- a/internal_packages/thread-search-index/lib/search-index-store.es6 +++ b/internal_packages/thread-search-index/lib/search-index-store.es6 @@ -46,6 +46,7 @@ class SearchIndexStore { * We only want to build the entire index if: * - It doesn't exist yet * - It is too big + * - We bumped the index version * * Otherwise, we just want to index accounts that haven't been indexed yet. * An account may not have been indexed if it is added and the app is closed @@ -158,9 +159,7 @@ class SearchIndexStore { getUnindexedAccounts() { return Promise.resolve(this.accountIds) - .filter((accId) => ( - DatabaseStore.isIndexEmptyForAccount(accId, Thread) - )) + .filter((accId) => DatabaseStore.isIndexEmptyForAccount(accId, Thread)) } indexThreadsForAccount(accountId, indexSize) { @@ -209,18 +208,16 @@ class SearchIndexStore { const messageBodies = ( thread.messages() .then((messages) => ( - Promise.resolve( - messages - .map(({body, snippet}) => ( - !_.isString(body) ? - {snippet} : - {body: QuotedHTMLTransformer.removeQuotedHTML(body)} - )) - .map(({body, snippet}) => ( - snippet || Utils.extractTextFromHtml(body, {maxLength: MESSAGE_BODY_LENGTH}).replace(/(\s)+/g, ' ') - )) - .join(' ') - ) + messages + .map(({body, snippet}) => ( + !_.isString(body) ? + {snippet} : + {body: QuotedHTMLTransformer.removeQuotedHTML(body)} + )) + .map(({body, snippet}) => ( + snippet || Utils.extractTextFromHtml(body, {maxLength: MESSAGE_BODY_LENGTH}).replace(/(\s)+/g, ' ') + )) + .join(' ') )) ) const participants = ( diff --git a/src/flux/attributes/matcher.es6 b/src/flux/attributes/matcher.es6 index a363cf45f..7ed5ae94d 100644 --- a/src/flux/attributes/matcher.es6 +++ b/src/flux/attributes/matcher.es6 @@ -273,7 +273,7 @@ class SearchMatcher extends Matcher { whereSQL(klass) { const searchTable = `${klass.name}Search` - return `\`${searchTable}\` MATCH '"${this.searchQuery}"'`; + return `\`${searchTable}\` MATCH '"${this.searchQuery}"*'`; } }