-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix IndexSearcherWrapper visibility (#39071)
* Fix IndexSearcherWrapper visibility This change adds a wrapper for IndexSearcher that makes IndexSearcher#search(List, Weight, Collector) visible by sub-classes. The wrapper is used by the ContextIndexSearcher to call this protected method on a searcher created by a plugin. This ensures that an override of the protected method in an IndexSearcherWrapper plugin is called when a search is executed. Closes #30758
- Loading branch information
Showing
4 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
server/src/main/java/org/apache/lucene/search/XIndexSearcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.lucene.search; | ||
|
||
import org.apache.lucene.index.LeafReaderContext; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* A wrapper for {@link IndexSearcher} that makes {@link IndexSearcher#search(List, Weight, Collector)} | ||
* visible by sub-classes. | ||
*/ | ||
public class XIndexSearcher extends IndexSearcher { | ||
private final IndexSearcher in; | ||
|
||
public XIndexSearcher(IndexSearcher in) { | ||
super(in.getIndexReader()); | ||
this.in = in; | ||
setSimilarity(in.getSimilarity()); | ||
setQueryCache(in.getQueryCache()); | ||
setQueryCachingPolicy(in.getQueryCachingPolicy()); | ||
} | ||
|
||
@Override | ||
public void search(List<LeafReaderContext> leaves, Weight weight, Collector collector) throws IOException { | ||
in.search(leaves, weight, collector); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters