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
This commit is contained in:
Juan Tejada 2016-09-28 11:03:41 -07:00
parent e10a0668ed
commit 4f8ad70d60
3 changed files with 14 additions and 17 deletions

View file

@ -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,

View file

@ -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 = (

View file

@ -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}"*'`;
}
}