Java 类org.apache.lucene.search.AssertingIndexSearcher 实例源码

项目:elasticsearch_my    文件:MockEngineSupport.java   
public Engine.Searcher wrapSearcher(String source, Engine.Searcher engineSearcher, IndexSearcher searcher, SearcherManager manager) {
    final AssertingIndexSearcher assertingIndexSearcher = newSearcher(source, searcher, manager);
    assertingIndexSearcher.setSimilarity(searcher.getSimilarity(true));
    // pass the original searcher to the super.newSearcher() method to make sure this is the searcher that will
    // be released later on. If we wrap an index reader here must not pass the wrapped version to the manager
    // on release otherwise the reader will be closed too early. - good news, stuff will fail all over the place if we don't get this right here
    AssertingSearcher assertingSearcher = new AssertingSearcher(assertingIndexSearcher, engineSearcher, shardId, logger) {
        @Override
        public void close() {
            try {
                searcherCloseable.remove(this);
            } finally {
                super.close();
            }
        }
    };
    searcherCloseable.add(assertingSearcher, engineSearcher.source());
    return assertingSearcher;
}
项目:elasticsearch_my    文件:MockEngineSupport.java   
public AssertingIndexSearcher newSearcher(String source, IndexSearcher searcher, SearcherManager manager) throws EngineException {
    IndexReader reader = searcher.getIndexReader();
    IndexReader wrappedReader = reader;
    assert reader != null;
    if (reader instanceof DirectoryReader && mockContext.wrapReader) {
        wrappedReader = wrapReader((DirectoryReader) reader);
    }
    // this executes basic query checks and asserts that weights are normalized only once etc.
    final AssertingIndexSearcher assertingIndexSearcher = new AssertingIndexSearcher(mockContext.random, wrappedReader);
    assertingIndexSearcher.setSimilarity(searcher.getSimilarity(true));
    assertingIndexSearcher.setQueryCache(filterCache);
    assertingIndexSearcher.setQueryCachingPolicy(filterCachingPolicy);
    return assertingIndexSearcher;
}