Skip to content

Commit

Permalink
Rename QueryPhase actors like Suggest, Rescore to be processors rathe…
Browse files Browse the repository at this point in the history
…r than phase (opensearch-project#8025) (opensearch-project#8067)

Signed-off-by: Sorabh Hamirwasia <sohami.apache@gmail.com>
  • Loading branch information
sohami authored and gaiksaya committed Jun 26, 2023
1 parent 440a0e7 commit 46de82e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Change `com.amazonaws.sdk.stsEndpointOverride` to `aws.stsEndpointOverride` ([7372](https://github.com/opensearch-project/OpenSearch/pull/7372/))
- Add new query profile collector fields with concurrent search execution ([#7898](https://github.com/opensearch-project/OpenSearch/pull/7898))
- Align range and default value for deletes_pct_allowed in merge policy ([#7730](https://github.com/opensearch-project/OpenSearch/pull/7730))
- Rename QueryPhase actors like Suggest, Rescore to be processors rather than phase ([#8025](https://github.com/opensearch-project/OpenSearch/pull/8025))

### Deprecated

Expand Down
18 changes: 9 additions & 9 deletions server/src/main/java/org/opensearch/search/query/QueryPhase.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
import org.opensearch.search.profile.ProfileShardResult;
import org.opensearch.search.profile.SearchProfileShardResults;
import org.opensearch.search.profile.query.InternalProfileCollector;
import org.opensearch.search.rescore.RescorePhase;
import org.opensearch.search.rescore.RescoreProcessor;
import org.opensearch.search.sort.SortAndFormats;
import org.opensearch.search.suggest.SuggestPhase;
import org.opensearch.search.suggest.SuggestProcessor;
import org.opensearch.tasks.TaskCancelledException;
import org.opensearch.threadpool.ThreadPool;

Expand Down Expand Up @@ -94,17 +94,17 @@ public class QueryPhase {
public static final boolean SYS_PROP_REWRITE_SORT = Booleans.parseBoolean(System.getProperty("opensearch.search.rewrite_sort", "true"));
public static final QueryPhaseSearcher DEFAULT_QUERY_PHASE_SEARCHER = new DefaultQueryPhaseSearcher();
private final QueryPhaseSearcher queryPhaseSearcher;
private final SuggestPhase suggestPhase;
private final RescorePhase rescorePhase;
private final SuggestProcessor suggestProcessor;
private final RescoreProcessor rescoreProcessor;

public QueryPhase() {
this(DEFAULT_QUERY_PHASE_SEARCHER);
}

public QueryPhase(QueryPhaseSearcher queryPhaseSearcher) {
this.queryPhaseSearcher = Objects.requireNonNull(queryPhaseSearcher, "QueryPhaseSearcher is required");
this.suggestPhase = new SuggestPhase();
this.rescorePhase = new RescorePhase();
this.suggestProcessor = new SuggestProcessor();
this.rescoreProcessor = new RescoreProcessor();
}

public void preProcess(SearchContext context) {
Expand All @@ -130,7 +130,7 @@ public void preProcess(SearchContext context) {

public void execute(SearchContext searchContext) throws QueryPhaseExecutionException {
if (searchContext.hasOnlySuggest()) {
suggestPhase.execute(searchContext);
suggestProcessor.process(searchContext);
searchContext.queryResult()
.topDocs(
new TopDocsAndMaxScore(new TopDocs(new TotalHits(0, TotalHits.Relation.EQUAL_TO), Lucene.EMPTY_SCORE_DOCS), Float.NaN),
Expand All @@ -151,9 +151,9 @@ public void execute(SearchContext searchContext) throws QueryPhaseExecutionExcep
boolean rescore = executeInternal(searchContext, queryPhaseSearcher);

if (rescore) { // only if we do a regular search
rescorePhase.execute(searchContext);
rescoreProcessor.process(searchContext);
}
suggestPhase.execute(searchContext);
suggestProcessor.process(searchContext);
aggregationProcessor.postProcess(searchContext);

if (searchContext.getProfilers() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
import java.io.IOException;

/**
* Rescore phase of a search request, used to run potentially expensive scoring models against the top matching documents.
* RescoreProcessor of a search request, used to run potentially expensive scoring models against the top matching documents.
*
* @opensearch.internal
*/
public class RescorePhase {
public class RescoreProcessor {

public void execute(SearchContext context) {
public void process(SearchContext context) {
TopDocs topDocs = context.queryResult().topDocs().topDocs;
if (topDocs.scoreDocs.length == 0) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
import java.util.Map;

/**
* Suggest phase of a search request, used to collect suggestions
* SuggestProcessor of a search request, used to collect suggestions
*
* @opensearch.internal
*/
public class SuggestPhase {
public class SuggestProcessor {

public void execute(SearchContext context) {
public void process(SearchContext context) {
final SuggestionSearchContext suggest = context.suggest();
if (suggest == null) {
return;
Expand Down

0 comments on commit 46de82e

Please sign in to comment.