Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
  @Override
  protected Searcher newSearcher(String source, IndexSearcher searcher, SearcherManager manager)
      throws EngineException {

    IndexReader reader = searcher.getIndexReader();
    IndexReader wrappedReader = reader;
    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());
    // 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
    return new AssertingSearcher(
        assertingIndexSearcher, super.newSearcher(source, searcher, manager), shardId);
  }