-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dynamic index and cluster setting for concurrent segment search (#…
…7956) * Add dynamic index and cluster setting for concurrent segment search Signed-off-by: Jay Deng <[email protected]> * Use feature flagged settings map Signed-off-by: Jay Deng <[email protected]> --------- Signed-off-by: Jay Deng <[email protected]>
- Loading branch information
Showing
17 changed files
with
334 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
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
82 changes: 82 additions & 0 deletions
82
server/src/main/java/org/opensearch/search/query/QueryPhaseSearcherWrapper.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,82 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.search.query; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.apache.lucene.search.Query; | ||
import org.opensearch.common.util.FeatureFlags; | ||
import org.opensearch.search.aggregations.AggregationProcessor; | ||
import org.opensearch.search.internal.ContextIndexSearcher; | ||
import org.opensearch.search.internal.SearchContext; | ||
import org.apache.lucene.search.CollectorManager; | ||
|
||
import java.io.IOException; | ||
import java.util.LinkedList; | ||
|
||
/** | ||
* Wrapper class for QueryPhaseSearcher that handles path selection for concurrent vs | ||
* non-concurrent search query phase and aggregation processor. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class QueryPhaseSearcherWrapper implements QueryPhaseSearcher { | ||
private static final Logger LOGGER = LogManager.getLogger(QueryPhaseSearcherWrapper.class); | ||
private final QueryPhaseSearcher defaultQueryPhaseSearcher; | ||
private final QueryPhaseSearcher concurrentQueryPhaseSearcher; | ||
|
||
public QueryPhaseSearcherWrapper() { | ||
this.defaultQueryPhaseSearcher = new QueryPhase.DefaultQueryPhaseSearcher(); | ||
this.concurrentQueryPhaseSearcher = FeatureFlags.isEnabled(FeatureFlags.CONCURRENT_SEGMENT_SEARCH) | ||
? new ConcurrentQueryPhaseSearcher() | ||
: null; | ||
} | ||
|
||
/** | ||
* Perform search using {@link CollectorManager} | ||
* | ||
* @param searchContext search context | ||
* @param searcher context index searcher | ||
* @param query query | ||
* @param hasTimeout "true" if timeout was set, "false" otherwise | ||
* @return is rescoring required or not | ||
* @throws java.io.IOException IOException | ||
*/ | ||
@Override | ||
public boolean searchWith( | ||
SearchContext searchContext, | ||
ContextIndexSearcher searcher, | ||
Query query, | ||
LinkedList<QueryCollectorContext> collectors, | ||
boolean hasFilterCollector, | ||
boolean hasTimeout | ||
) throws IOException { | ||
if (searchContext.isConcurrentSegmentSearchEnabled()) { | ||
LOGGER.info("Using concurrent search over segments (experimental)"); | ||
return concurrentQueryPhaseSearcher.searchWith(searchContext, searcher, query, collectors, hasFilterCollector, hasTimeout); | ||
} else { | ||
return defaultQueryPhaseSearcher.searchWith(searchContext, searcher, query, collectors, hasFilterCollector, hasTimeout); | ||
} | ||
} | ||
|
||
/** | ||
* {@link AggregationProcessor} to use to setup and post process aggregation related collectors during search request | ||
* @param searchContext search context | ||
* @return {@link AggregationProcessor} to use | ||
*/ | ||
@Override | ||
public AggregationProcessor aggregationProcessor(SearchContext searchContext) { | ||
if (searchContext.isConcurrentSegmentSearchEnabled()) { | ||
LOGGER.info("Using concurrent search over segments (experimental)"); | ||
return concurrentQueryPhaseSearcher.aggregationProcessor(searchContext); | ||
} else { | ||
return defaultQueryPhaseSearcher.aggregationProcessor(searchContext); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.