Package org.apache.lucene.util

Examples of org.apache.lucene.util.Version


      return false;
    }
  }

  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.valueOf( tmp );
        if ( log.isDebugEnabled() ) {
          log.debug( "Setting Lucene compatibility to Version " + version.name() );
        }
      }
      catch (IllegalArgumentException e) {
        StringBuilder msg = new StringBuilder( tmp );
        msg.append( " is an invalid value for the Lucene match version. Possible values are: " );
View Full Code Here


        try {
          // first try to use a ctor with version parameter
          // (needed for many new Analyzers that have no default one anymore)
          Constructor<? extends Analyzer> cnstr = clazz.getConstructor(Version.class);
          final String matchVersionStr = DOMUtil.getAttr(attrs, LUCENE_MATCH_VERSION_PARAM);
          final Version luceneMatchVersion = (matchVersionStr == null) ?
            solrConfig.luceneMatchVersion : Config.parseLuceneVersionString(matchVersionStr);
          if (luceneMatchVersion == null) {
            throw new SolrException
              ( SolrException.ErrorCode.SERVER_ERROR,
                "Configuration Error: Analyzer '" + clazz.getName() +
View Full Code Here

    runData.setIndexWriter(configureWriter(config, runData, OpenMode.CREATE, null));
    return 1;
  }
 
  public static IndexWriterConfig createWriterConfig(Config config, PerfRunData runData, OpenMode mode, IndexCommit commit) {
    Version version = Version.valueOf(config.get("writer.version", Version.LUCENE_31.toString()));
    IndexWriterConfig iwConf = new IndexWriterConfig(version, runData.getAnalyzer());
    iwConf.setOpenMode(mode);
    IndexDeletionPolicy indexDeletionPolicy = getIndexDeletionPolicy(config);
    iwConf.setIndexDeletionPolicy(indexDeletionPolicy);
    if(commit != null)
View Full Code Here

        if ( !create )
        {
            dropIndexDirectories( schema, table, textcol );
        }

        Version luceneVersion = LuceneUtils.currentVersion();

        // create the new directory
        DerbyLuceneDir  derbyLuceneDir = getDerbyLuceneDir( conn, schema, table, textcol );

        // get the Analyzer and the field names. use the default if the user didn't specify an override
        if ( indexDescriptorMaker == null ) { indexDescriptorMaker = LuceneUtils.class.getName() + ".defaultIndexDescriptor"; }
        LuceneIndexDescriptor   indexDescriptor = getIndexDescriptor( indexDescriptorMaker );
        String[]  fieldNames = indexDescriptor.getFieldNames();
        Analyzer    analyzer = indexDescriptor.getAnalyzer();

        // make sure the field names don't overlap with the key names
        sortAndVetFieldNames( fieldNames, primaryKeys );

        Properties  indexProperties = new Properties();
        indexProperties.setProperty( LUCENE_VERSION, luceneVersion.toString() );
        indexProperties.setProperty( UPDATE_TIMESTAMP, Long.toString( System.currentTimeMillis() ) );
        indexProperties.setProperty( INDEX_DESCRIPTOR_MAKER, indexDescriptorMaker );
        indexProperties.setProperty( ANALYZER, analyzer.getClass().getName() );
           
        StringBuilder   tableFunction = new StringBuilder();
View Full Code Here

    /** Get the version of the Lucene library on the classpath. */
    @SuppressWarnings("deprecation")
    public  static  Version currentVersion()
    {
        Version retval = null;

        // the current version is the highest one
        for ( Version current : Version.values() )
        {
            if ( current == Version.LUCENE_CURRENT ) { continue; }
View Full Code Here

     * </p>
     */
    private void    vetLuceneVersion( String indexVersionString )
        throws SQLException
    {
        Version     currentVersion = LuceneUtils.currentVersion();
        Version     indexVersion = null;

        try {
            indexVersion = Version.parseLeniently(indexVersionString);
        }
        catch (Exception e) {}
View Full Code Here

    try {
     instance = clazz.newInstance();
    } catch (Exception e) {
      throw new RuntimeException("Line #" + lineno(stok) + ": ", e);
    }
    Version luceneMatchVersion = null;
    Map<String,String> argMap = new HashMap<String,String>();
    boolean parenthetical = false;
    try {
      WHILE_LOOP: while (stok.nextToken() != StreamTokenizer.TT_EOF) {
        switch (stok.ttype) {
View Full Code Here

    runData.setIndexWriter(configureWriter(config, runData, OpenMode.CREATE, null));
    return 1;
  }
 
  public static IndexWriterConfig createWriterConfig(Config config, PerfRunData runData, OpenMode mode, IndexCommit commit) {
    @SuppressWarnings("deprecation")
    Version version = Version.parseLeniently(config.get("writer.version", Version.LUCENE_CURRENT.toString()));
    IndexWriterConfig iwConf = new IndexWriterConfig(version, runData.getAnalyzer());
    iwConf.setOpenMode(mode);
    IndexDeletionPolicy indexDeletionPolicy = getIndexDeletionPolicy(config);
    iwConf.setIndexDeletionPolicy(indexDeletionPolicy);
View Full Code Here

  private final Map<Integer,MonotonicBlockPackedReader> ordIndexInstances = new HashMap<>();
 
  /** expert: instantiates a new reader */
  @SuppressWarnings("deprecation")
  protected Lucene45DocValuesProducer(SegmentReadState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension) throws IOException {
    Version ver;
    try {
      ver = Version.parseLeniently(state.segmentInfo.getVersion());
    } catch (IllegalArgumentException e) {
      ver = null;
    }
    lenientFieldInfoCheck = ver == null || !ver.onOrAfter(Version.LUCENE_4_9);
    String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
    // read in the entries from the metadata file.
    ChecksumIndexInput in = state.directory.openChecksumInput(metaName, state.context);
    this.maxDoc = state.segmentInfo.getDocCount();
    boolean success = false;
View Full Code Here

        dvProducersByField.put(fi.name, dvp);
      }
      return;
    }

    Version ver;
    try {
      ver = Version.parseLeniently(si.info.getVersion());
    } catch (IllegalArgumentException e) {
      // happened in TestBackwardsCompatibility on a 4.0.0.2 index (no matching
      // Version constant), anyway it's a pre-4.9 index.
      ver = null;
    }
    if (ver != null && ver.onOrAfter(Version.LUCENE_4_9)) {
      DocValuesProducer baseProducer = null;
      for (FieldInfo fi : fieldInfos) {
        if (!fi.hasDocValues()) continue;
        long docValuesGen = fi.getDocValuesGen();
        if (docValuesGen == -1) {
View Full Code Here

TOP

Related Classes of org.apache.lucene.util.Version

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.