public EmojiTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); config = new DefaultICUTokenizerConfig(true, true) { @Override public BreakIterator getBreakIterator(int script) { // Load the ICU default rules RuleBasedBreakIterator rbbi = (RuleBasedBreakIterator) BreakIterator.getWordInstance(Locale.getDefault()); String defaultRules = rbbi.toString(); // Customize the rules to add EmojiNRK as first class word defaultRules = defaultRules.replace( "!!forward;", "!!forward;\n$EmojiNRK {200};" ); defaultRules = defaultRules.replace( "| $ZWJ)*;", "| $ZWJ)* {200};" ); return new RuleBasedBreakIterator(defaultRules); } }; }