Java 类org.apache.lucene.index.sorter.SortingMergePolicy 实例源码

项目:linden    文件:EarlyTerminationCollector.java   
@Override
public void setNextReader(AtomicReaderContext context) throws IOException {
  collector.setNextReader(context);
  if (sort != null) {
    segmentSorted = SortingMergePolicy.isSorted(context.reader(), sort);
    segmentTotalCollect = segmentSorted ? numDocsToCollectPerSortedSegment : 2147483647;
  } else {
    segmentTotalCollect = numDocsToCollectPerSortedSegment;
  }
  numCollected = 0;
}
项目:search    文件:AnalyzingInfixSuggester.java   
/** Override this to customize index settings, e.g. which
 *  codec to use. */
protected IndexWriterConfig getIndexWriterConfig(Version matchVersion, Analyzer indexAnalyzer, IndexWriterConfig.OpenMode openMode) {
  IndexWriterConfig iwc = new IndexWriterConfig(matchVersion, indexAnalyzer);
  iwc.setCodec(new Lucene410Codec());
  iwc.setOpenMode(openMode);

  // This way all merged segments will be sorted at
  // merge time, allow for per-segment early termination
  // when those segments are searched:
  iwc.setMergePolicy(new SortingMergePolicy(iwc.getMergePolicy(), SORT));

  return iwc;
}
项目:read-open-source-code    文件:AnalyzingInfixSuggester.java   
/** Override this to customize index settings, e.g. which
 *  codec to use. */
protected IndexWriterConfig getIndexWriterConfig(Version matchVersion, Analyzer indexAnalyzer, IndexWriterConfig.OpenMode openMode) {
  IndexWriterConfig iwc = new IndexWriterConfig(matchVersion, indexAnalyzer);
  iwc.setCodec(new Lucene410Codec());
  iwc.setOpenMode(openMode);

  // This way all merged segments will be sorted at
  // merge time, allow for per-segment early termination
  // when those segments are searched:
  iwc.setMergePolicy(new SortingMergePolicy(iwc.getMergePolicy(), SORT));

  return iwc;
}
项目:linden    文件:SortingMergePolicyDecorator.java   
public SortingMergePolicyDecorator(MergePolicy in, Sort sort) {
  this.sortingMergePolicy = new SortingMergePolicy(in, sort);
  this.sort = sort;
}
项目:stratio-cassandra    文件:LuceneIndex.java   
/**
 * Initializes this using the specified {@link Sort} for trying to keep the {@link Document}s sorted.
 *
 * @param sort The {@link Sort} to be used.
 */
public void init(Sort sort) {
    Log.debug("Initializing index");
    try {
        this.sort = sort;

        // Get directory file
        file = new File(path);

        // Open or create directory
        FSDirectory fsDirectory = FSDirectory.open(file);
        directory = new NRTCachingDirectory(fsDirectory, maxMergeMB, maxCachedMB);

        // Setup index writer
        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_48, analyzer);
        config.setRAMBufferSizeMB(ramBufferMB);
        config.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
        config.setUseCompoundFile(true);
        config.setMergePolicy(new SortingMergePolicy(config.getMergePolicy(), sort));
        indexWriter = new IndexWriter(directory, config);

        // Setup NRT search
        SearcherFactory searcherFactory = new SearcherFactory() {
            public IndexSearcher newSearcher(IndexReader reader) throws IOException {
                IndexSearcher searcher = new IndexSearcher(reader);
                searcher.setSimilarity(new NoIDFSimilarity());
                return searcher;
            }
        };
        TrackingIndexWriter trackingIndexWriter = new TrackingIndexWriter(indexWriter);
        searcherManager = new SearcherManager(indexWriter, true, searcherFactory);
        searcherReopener = new ControlledRealTimeReopenThread<>(trackingIndexWriter,
                                                                searcherManager,
                                                                refreshSeconds,
                                                                refreshSeconds);
        searcherReopener.start(); // Start the refresher thread
    } catch (IOException e) {
        Log.error(e, "Error while initializing index");
        throw new RuntimeException(e);
    }
}