Add emoticons to search index

exclude-unsupported-native-emojis
Etienne Lemay 2016-07-07 17:12:45 -04:00
parent 573ef818f5
commit 9e57de33ce
1 changed files with 12 additions and 1 deletions

View File

@ -14,6 +14,7 @@ export default class Search extends React.Component {
this.pipeline.reset()
this.field('short_name', { boost: 2 })
this.field('emoticons')
this.field('name')
this.ref('id')
@ -21,10 +22,16 @@ export default class Search extends React.Component {
for (let emoji in data.emojis) {
let emojiData = data.emojis[emoji],
{ short_name, name } = emojiData
{ short_name, name, text, texts } = emojiData
texts || (texts = [])
if (text && !texts.length) {
texts = [text]
}
this.index.add({
id: short_name,
emoticons: texts,
short_name: this.tokenize(short_name),
name: this.tokenize(name),
})
@ -36,6 +43,10 @@ export default class Search extends React.Component {
return string.split('')
}
if (/(:|;|=)-/.test(string)) {
return [string]
}
return string.split(/[-|_|\s]+/)
}