Java Code Examples for org.elasticsearch.common.regex.Regex#compile()
The following examples show how to use
org.elasticsearch.common.regex.Regex#compile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PatternAnalyzerProvider.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Inject public PatternAnalyzerProvider(Index index, IndexSettingsService indexSettingsService, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettingsService.getSettings(), name, settings); Version esVersion = Version.indexCreated(indexSettingsService.getSettings()); final CharArraySet defaultStopwords; if (esVersion.onOrAfter(Version.V_1_0_0_RC1)) { defaultStopwords = CharArraySet.EMPTY_SET; } else { defaultStopwords = StopAnalyzer.ENGLISH_STOP_WORDS_SET; } boolean lowercase = settings.getAsBoolean("lowercase", true); CharArraySet stopWords = Analysis.parseStopWords(env, settings, defaultStopwords); String sPattern = settings.get("pattern", "\\W+" /*PatternAnalyzer.NON_WORD_PATTERN*/); if (sPattern == null) { throw new IllegalArgumentException("Analyzer [" + name + "] of type pattern must have a `pattern` set"); } Pattern pattern = Regex.compile(sPattern, settings.get("flags")); analyzer = new PatternAnalyzer(pattern, lowercase, stopWords); }
Example 2
Source File: PatternTokenizerFactory.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Inject public PatternTokenizerFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) { super(index, indexSettingsService.getSettings(), name, settings); String sPattern = settings.get("pattern", "\\W+" /*PatternAnalyzer.NON_WORD_PATTERN*/); if (sPattern == null) { throw new IllegalArgumentException("pattern is missing for [" + name + "] tokenizer of type 'pattern'"); } this.pattern = Regex.compile(sPattern, settings.get("flags")); this.group = settings.getAsInt("group", -1); }
Example 3
Source File: PatternReplaceTokenFilterFactory.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Inject public PatternReplaceTokenFilterFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) { super(index, indexSettingsService.getSettings(), name, settings); String sPattern = settings.get("pattern", null); if (sPattern == null) { throw new IllegalArgumentException("pattern is missing for [" + name + "] token filter of type 'pattern_replace'"); } this.pattern = Regex.compile(sPattern, settings.get("flags")); this.replacement = settings.get("replacement", ""); this.all = settings.getAsBoolean("all", true); }
Example 4
Source File: PatternReplaceCharFilterFactory.java From crate with Apache License 2.0 | 5 votes |
PatternReplaceCharFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name); String sPattern = settings.get("pattern"); if (!Strings.hasLength(sPattern)) { throw new IllegalArgumentException("pattern is missing for [" + name + "] char filter of type 'pattern_replace'"); } pattern = Regex.compile(sPattern, settings.get("flags")); replacement = settings.get("replacement", ""); // when not set or set to "", use "". }
Example 5
Source File: PatternAnalyzerProvider.java From crate with Apache License 2.0 | 5 votes |
PatternAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name, settings); final CharArraySet defaultStopwords = CharArraySet.EMPTY_SET; boolean lowercase = settings.getAsBoolean("lowercase", true); CharArraySet stopWords = Analysis.parseStopWords(env, settings, defaultStopwords); String sPattern = settings.get("pattern", "\\W+" /*PatternAnalyzer.NON_WORD_PATTERN*/); if (sPattern == null) { throw new IllegalArgumentException("Analyzer [" + name + "] of type pattern must have a `pattern` set"); } Pattern pattern = Regex.compile(sPattern, settings.get("flags")); analyzer = new PatternAnalyzer(pattern, lowercase, stopWords); }
Example 6
Source File: PatternTokenizerFactory.java From crate with Apache License 2.0 | 5 votes |
PatternTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); String sPattern = settings.get("pattern", "\\W+" /*PatternAnalyzer.NON_WORD_PATTERN*/); if (sPattern == null) { throw new IllegalArgumentException("pattern is missing for [" + name + "] tokenizer of type 'pattern'"); } this.pattern = Regex.compile(sPattern, settings.get("flags")); this.group = settings.getAsInt("group", -1); }
Example 7
Source File: PatternReplaceTokenFilterFactory.java From crate with Apache License 2.0 | 5 votes |
public PatternReplaceTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); String sPattern = settings.get("pattern", null); if (sPattern == null) { throw new IllegalArgumentException("pattern is missing for [" + name + "] token filter of type 'pattern_replace'"); } this.pattern = Regex.compile(sPattern, settings.get("flags")); this.replacement = settings.get("replacement", ""); this.all = settings.getAsBoolean("all", true); }