private static Codec readCodec(DataInput input) throws IOException { final String name = input.readString(); try { return Codec.forName(name); } catch (IllegalArgumentException e) { // maybe it's an old default codec that moved if (name.startsWith("Lucene")) { throw new IllegalArgumentException("Could not load codec '" + name + "'. Did you forget to add lucene-backward-codecs.jar?", e); } throw e; } }
public CodecService(@Nullable MapperService mapperService, Logger logger) { final MapBuilder<String, Codec> codecs = MapBuilder.<String, Codec>newMapBuilder(); if (mapperService == null) { codecs.put(DEFAULT_CODEC, new Lucene70Codec()); codecs.put(BEST_COMPRESSION_CODEC, new Lucene70Codec(Mode.BEST_COMPRESSION)); } else { codecs.put(DEFAULT_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger)); codecs.put(BEST_COMPRESSION_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_COMPRESSION, mapperService, logger)); } codecs.put(LUCENE_DEFAULT_CODEC, Codec.getDefault()); for (String codec : Codec.availableCodecs()) { codecs.put(codec, Codec.forName(codec)); } this.codecs = codecs.immutableMap(); }
private static Codec readCodec(DataInput input) throws IOException { final String name = input.readString(); try { return Codec.forName(name); } catch (IllegalArgumentException e) { // maybe it's an old default codec that moved if (name.startsWith("Lucene")) { throw new IllegalArgumentException("Could not load codec '" + name + "'. Did you forget to add lucene-backward-codecs.jar?", e); } throw e; } }
private static Codec readCodec(DataInput input, boolean unsupportedAllowed) throws IOException { final String name = input.readString(); try { return Codec.forName(name); } catch (IllegalArgumentException e) { // give better error messages if we can, first check if this is a legacy codec if (unsupportedCodecs.contains(name)) { // We should only get here on pre-5.3 indices, but we can't test this until 7.0 when 5.x indices become too old: assert unsupportedAllowed; IOException newExc = new IndexFormatTooOldException(input, "Codec '" + name + "' is too old"); newExc.initCause(e); throw newExc; } // or maybe it's an old default codec that moved if (name.startsWith("Lucene")) { throw new IllegalArgumentException("Could not load codec '" + name + "'. Did you forget to add lucene-backward-codecs.jar?", e); } throw e; } }
private static Codec readCodec(DataInput input, boolean unsupportedAllowed) throws IOException { final String name = input.readString(); try { return Codec.forName(name); } catch (IllegalArgumentException e) { // give better error messages if we can, first check if this is a legacy codec if (unsupportedCodecs.contains(name)) { // We should only get here on pre-5.3 indices, but we can't test this until 7.0 when 5.x indices become too old: assert unsupportedAllowed; IOException newExc = new IndexFormatTooOldException(input, "Codec '" + name + "' is too old"); newExc.initCause(e); throw newExc; } // or maybe it's an old default codec that moved if (name.startsWith("Lucene")) { throw new IllegalArgumentException("Could not load codec '" + name + "'. Did you forget to add lucene-backward-codecs.jar?", e); } throw e; } }
private Codec createCodec() { String codecName = getOptionalValue(definition, LuceneIndexConstants.CODEC_NAME, null); Codec codec = null; if (codecName != null) { // prevent LUCENE-6482 // (also done in LuceneIndexProviderService, just to be save) OakCodec ensureLucene46CodecLoaded = new OakCodec(); // to ensure the JVM doesn't optimize away object creation // (probably not really needed; just to be save) log.debug("Lucene46Codec is loaded: {}", ensureLucene46CodecLoaded); codec = Codec.forName(codecName); log.debug("Codec is loaded: {}", codecName); } else if (fullTextEnabled) { codec = new OakCodec(); } return codec; }
private Codec createCodec() { String codecName = getOptionalValue(definition, LuceneIndexConstants.CODEC_NAME, null); Codec codec = null; if (codecName != null) { // prevent LUCENE-6482 // (also done in LuceneIndexProviderService, just to be save) OakCodec ensureLucene46CodecLoaded = new OakCodec(); // to ensure the JVM doesn't optimize away object creation // (probably not really needed; just to be save) log.debug("Lucene46Codec is loaded: {}", ensureLucene46CodecLoaded); codec = Codec.forName(codecName); log.debug("Codec is loaded: {}", codecName); } else if (fullTextEnabled) { codec = new OakCodec(); } return codec; }
public IndexWriter openLuceneIndex(File aIndexDir) throws IOException { Directory directory = FSDirectory.open(aIndexDir.toPath()); // Create parser configuration as a JSON object JSONObject jsonParserConfiguration = new JSONObject(); // Add the project id to the configuration jsonParserConfiguration.put("projectId", project.getId()); // Tokenizer parameters Map<String, String> paramsTokenizer = new HashMap<String, String>(); paramsTokenizer.put(MtasTokenizerFactory.ARGUMENT_PARSER, MTAS_PARSER); paramsTokenizer.put(MtasTokenizerFactory.ARGUMENT_PARSER_ARGS, jsonParserConfiguration.toString()); // Build analyzer Analyzer mtasAnalyzer = CustomAnalyzer.builder() .withTokenizer(MTAS_TOKENIZER, paramsTokenizer).build(); Map<String, Analyzer> analyzerPerField = new HashMap<String, Analyzer>(); analyzerPerField.put(FIELD_CONTENT, mtasAnalyzer); PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer(), analyzerPerField); // Build IndexWriter IndexWriterConfig config = new IndexWriterConfig(analyzer); config.setUseCompoundFile(false); config.setCodec(Codec.forName(MtasCodec.MTAS_CODEC_NAME)); return new IndexWriter(directory, config); }
public CodecService(@Nullable MapperService mapperService, Logger logger) { final MapBuilder<String, Codec> codecs = MapBuilder.<String, Codec>newMapBuilder(); if (mapperService == null) { codecs.put(DEFAULT_CODEC, new Lucene70Codec()); codecs.put(BEST_COMPRESSION_CODEC, new Lucene70Codec(Mode.BEST_COMPRESSION)); } else { codecs.put(DEFAULT_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger)); codecs.put(BEST_COMPRESSION_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_COMPRESSION, mapperService, logger)); } codecs.put(LUCENE_DEFAULT_CODEC, Codec.getDefault()); for (String codec : Codec.availableCodecs()) { codecs.put(codec, Codec.forName(codec)); } this.codecs = codecs.immutableMap(); }
public CodecService(@Nullable MapperService mapperService, Logger logger) { final MapBuilder<String, Codec> codecs = MapBuilder.<String, Codec>newMapBuilder(); if (mapperService == null) { codecs.put(DEFAULT_CODEC, new Lucene62Codec()); codecs.put(BEST_COMPRESSION_CODEC, new Lucene62Codec(Mode.BEST_COMPRESSION)); } else { codecs.put(DEFAULT_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger)); codecs.put(BEST_COMPRESSION_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_COMPRESSION, mapperService, logger)); } codecs.put(LUCENE_DEFAULT_CODEC, Codec.getDefault()); for (String codec : Codec.availableCodecs()) { codecs.put(codec, Codec.forName(codec)); } this.codecs = codecs.immutableMap(); }
private CodecService(Index index, Settings indexSettings, MapperService mapperService) { super(index, indexSettings); this.mapperService = mapperService; MapBuilder<String, Codec> codecs = MapBuilder.<String, Codec>newMapBuilder(); if (mapperService == null) { codecs.put(DEFAULT_CODEC, new Lucene54Codec()); codecs.put(BEST_COMPRESSION_CODEC, new Lucene54Codec(Mode.BEST_COMPRESSION)); } else { codecs.put(DEFAULT_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger)); codecs.put(BEST_COMPRESSION_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_COMPRESSION, mapperService, logger)); } codecs.put(LUCENE_DEFAULT_CODEC, Codec.getDefault()); for (String codec : Codec.availableCodecs()) { codecs.put(codec, Codec.forName(codec)); } this.codecs = codecs.immutableMap(); }
public CodecService(@Nullable MapperService mapperService, Logger logger) { final MapBuilder<String, Codec> codecs = MapBuilder.<String, Codec>newMapBuilder(); if (mapperService == null) { codecs.put(DEFAULT_CODEC, new Lucene70Codec()); codecs.put(BEST_COMPRESSION_CODEC, new Lucene70Codec(Mode.BEST_COMPRESSION)); } else { codecs.put(DEFAULT_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger)); codecs.put(BEST_COMPRESSION_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_COMPRESSION, mapperService, logger)); } codecs.put(LUCENE_DEFAULT_CODEC, Codec.getDefault()); for (String codec : Codec.availableCodecs()) { codecs.put(codec, Codec.forName(codec)); } this.codecs = codecs.immutableMap(); }