org.apache.lucene.util.Version.parseLeniently()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.apache.lucene.util.Version.parseLeniently()方法的一些代码示例,展示了Version.parseLeniently()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.parseLeniently()方法的具体详情如下:
包路径:org.apache.lucene.util.Version
类名称:Version
方法名:parseLeniently

Version.parseLeniently介绍

[英]Parse the given version number as a constant or dot based version.

This method allows to use "LUCENE_X_Y" constant names, or version numbers in the format "x.y.z".
[中]将给定的版本号解析为常量或基于点的版本。
此方法允许使用“LUCENE_X_Y”常量名称,或格式为“X.Y.z”的版本号。

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

public static Version parse(String toParse, Version defaultValue) {
    if (Strings.hasLength(toParse)) {
      try {
        return Version.parseLeniently(toParse);
      } catch (ParseException e) {
        // pass to default
      }
    }
    return defaultValue;
  }
}

代码示例来源:origin: org.apache.lucene/lucene-analyzers-common

/**
 * Initialize this factory via a set of key-value pairs.
 */
protected AbstractAnalysisFactory(Map<String,String> args) {
 originalArgs = Collections.unmodifiableMap(new HashMap<>(args));
 String version = get(args, LUCENE_MATCH_VERSION_PARAM);
 if (version == null) {
  luceneMatchVersion = Version.LATEST;
 } else {
  try {
   luceneMatchVersion = Version.parseLeniently(version);
  } catch (ParseException pe) {
   throw new IllegalArgumentException(pe);
  }
 }
 args.remove(CLASS_NAME);  // consume the class arg
}

代码示例来源:origin: org.apache.jackrabbit/oak-lucene

@SuppressWarnings("deprecation")
private static Version parseLuceneVersionString(final String matchVersion) {
  final Version version = Version.parseLeniently(matchVersion);
  if (version == Version.LUCENE_CURRENT && !versionWarningAlreadyLogged.getAndSet(true)) {
    log.warn(
        "You should not use LATEST as luceneMatchVersion property: "+
            "if you use this setting, and then Solr upgrades to a newer release of Lucene, "+
            "sizable changes may happen. If precise back compatibility is important "+
            "then you should instead explicitly specify an actual Lucene version."
    );
  }
  return version;
}

代码示例来源:origin: apache/jackrabbit-oak

@SuppressWarnings("deprecation")
private static Version parseLuceneVersionString(final String matchVersion) {
  final Version version = Version.parseLeniently(matchVersion);
  if (version == Version.LUCENE_CURRENT && !versionWarningAlreadyLogged.getAndSet(true)) {
    log.warn(
        "You should not use LATEST as luceneMatchVersion property: "+
            "if you use this setting, and then Solr upgrades to a newer release of Lucene, "+
            "sizable changes may happen. If precise back compatibility is important "+
            "then you should instead explicitly specify an actual Lucene version."
    );
  }
  return version;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

public static Version parse(String toParse, Version defaultValue) {
    if (Strings.hasLength(toParse)) {
      try {
        return Version.parseLeniently(toParse);
      } catch (ParseException e) {
        // pass to default
      }
    }
    return defaultValue;
  }
}

代码示例来源:origin: apache/servicemix-bundles

public static Version parse(String toParse, Version defaultValue) {
    if (Strings.hasLength(toParse)) {
      try {
        return Version.parseLeniently(toParse);
      } catch (ParseException e) {
        // pass to default
      }
    }
    return defaultValue;
  }
}

代码示例来源:origin: hibernate/hibernate-search

private static Version parseLuceneVersion(String versionString) {
    try {
      return Version.parseLeniently( versionString );
    }
    catch (IllegalArgumentException | ParseException e) {
      throw log.illegalLuceneVersionFormat( versionString, e.getMessage(), e );
    }
  }
}

代码示例来源:origin: org.codelibs/elasticsearch-querybuilders

public static Version parse(String toParse, Version defaultValue) {
    if (Strings.hasLength(toParse)) {
      try {
        return Version.parseLeniently(toParse);
      } catch (ParseException e) {
        // pass to default
      }
    }
    return defaultValue;
  }
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

public static Version parse(String toParse, Version defaultValue) {
    if (Strings.hasLength(toParse)) {
      try {
        return Version.parseLeniently(toParse);
      } catch (ParseException e) {
        // pass to default
      }
    }
    return defaultValue;
  }
}

代码示例来源:origin: harbby/presto-connectors

public static Version parse(String toParse, Version defaultValue) {
    if (Strings.hasLength(toParse)) {
      try {
        return Version.parseLeniently(toParse);
      } catch (ParseException e) {
        // pass to default
      }
    }
    return defaultValue;
  }
}

代码示例来源:origin: shilad/wikibrain

/**
 * Used by provider only.
 */
private LuceneOptions(String name, Configurator configurator, String matchVersion, String luceneRoot, List<String> namespaces, TokenizerOptions options, TextFieldElements elements) {
  this.name = name;
  this.configurator = configurator;
  this.matchVersion = Version.parseLeniently(matchVersion);
  this.luceneRoot = new File(luceneRoot);
  this.namespaces = new ArrayList<NameSpace>();
  for (String s : namespaces) {
    this.namespaces.add(NameSpace.getNameSpaceByName(s));
  }
  this.options = options;
  this.elements = elements;
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

/**
 * Initialize this factory via a set of key-value pairs.
 */
protected AbstractAnalysisFactory(Map<String,String> args) {
 originalArgs = Collections.unmodifiableMap(new HashMap<>(args));
 String version = get(args, LUCENE_MATCH_VERSION_PARAM);
 if (version == null) {
  luceneMatchVersion = Version.LATEST;
 } else {
  try {
   luceneMatchVersion = Version.parseLeniently(version);
  } catch (ParseException pe) {
   throw new IllegalArgumentException(pe);
  }
 }
 args.remove(CLASS_NAME);  // consume the class arg
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Initialize this factory via a set of key-value pairs.
 */
protected AbstractAnalysisFactory(Map<String,String> args) {
 originalArgs = Collections.unmodifiableMap(new HashMap<>(args));
 String version = get(args, LUCENE_MATCH_VERSION_PARAM);
 if (version == null) {
  luceneMatchVersion = Version.LATEST;
 } else {
  try {
   luceneMatchVersion = Version.parseLeniently(version);
  } catch (ParseException pe) {
   throw new IllegalArgumentException(pe);
  }
 }
 args.remove(CLASS_NAME);  // consume the class arg
}

代码示例来源:origin: shilad/wikibrain

@Override
  public StringNormalizer get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException {
    if (!config.getString("type").equals("lucene")) {
      return null;
    }
    Version version = Version.parseLeniently(config.getString("version"));
    TokenizerOptions opts = new TokenizerOptions(
                  config.getBoolean("caseInsensitive"),
                  config.getBoolean("useStopWords"),
                  config.getBoolean("useStem")
              );
    return new LuceneStringNormalizer(opts, version);
  }
}

代码示例来源:origin: kite-sdk/kite

private static Version getMinorLuceneVersion(String version) {
 try {
  return Version.parseLeniently(version.replaceFirst("^(\\d)\\.(\\d).*", "LUCENE_$1$2"));
 } catch (ParseException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: net.bolbat/bb-kit

try {
  this.version = Version.parseLeniently(config.getVersion());

代码示例来源:origin: hibernate/hibernate-search

private Version getLuceneMatchVersion(SearchConfiguration cfg) {
    final Version version;
    String tmp = cfg.getProperty( Environment.LUCENE_MATCH_VERSION );
    if ( StringHelper.isEmpty( tmp ) ) {
      log.recommendConfiguringLuceneVersion();
      version = Environment.DEFAULT_LUCENE_MATCH_VERSION;
    }
    else {
      try {
        version = Version.parseLeniently( tmp );
        if ( log.isDebugEnabled() ) {
          log.debug( "Setting Lucene compatibility to Version " + version );
        }
      }
      catch (IllegalArgumentException e) {
        throw log.illegalLuceneVersionFormat( tmp, e.getMessage() );
      }
      catch (ParseException e) {
        throw log.illegalLuceneVersionFormat( tmp, e.getMessage() );
      }
    }
    return version;
  }
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

private Version getLuceneMatchVersion(SearchConfiguration cfg) {
  final Version version;
  String tmp = cfg.getProperty( Environment.LUCENE_MATCH_VERSION );
  if ( StringHelper.isEmpty( tmp ) ) {
    log.recommendConfiguringLuceneVersion();
    version = Environment.DEFAULT_LUCENE_MATCH_VERSION;
  }
  else {
    try {
      version = Version.parseLeniently( tmp );
      if ( log.isDebugEnabled() ) {
        log.debug( "Setting Lucene compatibility to Version " + version );
      }
    }
    catch (IllegalArgumentException e) {
      throw log.illegalLuceneVersionFormat( tmp, e.getMessage() );
    }
    catch (ParseException e) {
      throw log.illegalLuceneVersionFormat( tmp, e.getMessage() );
    }
  }
  return version;
}

相关文章