org.apache.lucene.analysis.pattern.PatternReplaceFilterFactory Java Examples
The following examples show how to use
org.apache.lucene.analysis.pattern.PatternReplaceFilterFactory.
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: NestPathField.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void setArgs(IndexSchema schema, Map<String, String> args) { args.putIfAbsent("stored", "false"); args.putIfAbsent("omitTermFreqAndPositions", "true"); args.putIfAbsent("omitNorms", "true"); args.putIfAbsent("maxCharsForDocValues", "-1"); super.setArgs(schema, args); // CustomAnalyzer is easy to use CustomAnalyzer customAnalyzer; try { customAnalyzer = CustomAnalyzer.builder(schema.getResourceLoader()) .withDefaultMatchVersion(schema.getDefaultLuceneMatchVersion()) .withTokenizer(KeywordTokenizerFactory.class) .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "#\\d*", "replace", "all") .build(); } catch (IOException e) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);//impossible? } // Solr HTTP Schema APIs don't know about CustomAnalyzer so use TokenizerChain instead setIndexAnalyzer(new TokenizerChain(customAnalyzer)); // leave queryAnalyzer as literal }
Example #2
Source File: AnalyzerFactory.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
private void addTokenFilterForUnderscoreRemovalAroundToken(Builder builder) throws IOException { builder .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "^\\_", "replacement", "", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\_$", "replacement", "", "replace", "all"); }
Example #3
Source File: AnalyzerFactory.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
private void addTokenFilterForTokenToDomainValue(Builder builder) throws IOException { builder .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\(", "replacement", "", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\)$", "replacement", "", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\)", "replacement", " ", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\{\\}", "replacement", "\\{ \\}", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\[\\]", "replacement", "\\[ \\]", "replace", "all"); }
Example #4
Source File: AnalyzerFactory.java From airsonic with GNU General Public License v3.0 | 5 votes |
private void addTokenFilterForUnderscoreRemovalAroundToken(Builder builder) throws IOException { builder .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "^\\_", "replacement", "", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\_$", "replacement", "", "replace", "all"); }
Example #5
Source File: AnalyzerFactory.java From airsonic with GNU General Public License v3.0 | 5 votes |
private void addTokenFilterForTokenToDomainValue(Builder builder) throws IOException { builder .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\(", "replacement", "", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\)$", "replacement", "", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\)", "replacement", " ", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\{\\}", "replacement", "\\{ \\}", "replace", "all") .addTokenFilter(PatternReplaceFilterFactory.class, "pattern", "\\[\\]", "replacement", "\\[ \\]", "replace", "all"); }