Skip to content
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
57ec072
iter
pmpailis Aug 28, 2024
5e5839e
Merge remote-tracking branch 'origin/main' into rework_rrf_to_work_th…
pmpailis Aug 28, 2024
73f4f8f
iter
pmpailis Aug 28, 2024
115ea36
reworking explain and profile
pmpailis Sep 2, 2024
3bff589
iter
pmpailis Sep 2, 2024
191307a
adding tests
pmpailis Sep 4, 2024
78b193b
adding tests
pmpailis Sep 4, 2024
3e0574a
revert gradle cluster setup
pmpailis Sep 4, 2024
b33fa45
Merge remote-tracking branch 'origin/main' into rework_rrf_to_work_th…
pmpailis Sep 4, 2024
2c6c2c6
iter
pmpailis Sep 4, 2024
32ccffd
iter
pmpailis Sep 4, 2024
8cebaf7
iter
pmpailis Sep 4, 2024
7d0a7a1
iter
pmpailis Sep 4, 2024
7490ac9
iter
pmpailis Sep 4, 2024
87449fc
Merge remote-tracking branch 'origin/main' into rework_rrf_to_work_th…
pmpailis Sep 5, 2024
1222284
iter
pmpailis Sep 6, 2024
6d23639
iter
pmpailis Sep 6, 2024
e03c48e
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
pmpailis Sep 9, 2024
e6387ab
restoring
pmpailis Sep 9, 2024
18a9c74
Merge branch 'rework_rrf_to_work_through_rewrite_phase' of github.com…
pmpailis Sep 9, 2024
ab40ea5
iter
pmpailis Sep 9, 2024
0179298
spotless
pmpailis Sep 9, 2024
26f89b6
iter
pmpailis Sep 9, 2024
20f4047
iter
pmpailis Sep 10, 2024
ff78c5e
Merge remote-tracking branch 'origin/main' into rework_rrf_to_work_th…
pmpailis Sep 10, 2024
db9b469
iter
pmpailis Sep 10, 2024
9388c02
iter
pmpailis Sep 10, 2024
a7935af
iter
pmpailis Sep 10, 2024
5d5fe89
iter
pmpailis Sep 11, 2024
d26053e
adding highlighter tests and retriever-based pagination
pmpailis Sep 11, 2024
8decb0a
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
pmpailis Sep 11, 2024
ebdd321
removing outdated test
pmpailis Sep 11, 2024
598345e
adding tests for min_score and collapse
pmpailis Sep 11, 2024
b4a182c
iter
pmpailis Sep 11, 2024
57214b8
addressing PR comments
pmpailis Sep 12, 2024
24c4c6e
addressing PR comments
pmpailis Sep 12, 2024
2c9a597
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
pmpailis Sep 12, 2024
27ae7cb
iter
pmpailis Sep 12, 2024
8866345
updating tests after latest changes
pmpailis Sep 12, 2024
5e08637
iter
pmpailis Sep 12, 2024
5179aa5
iter
pmpailis Sep 12, 2024
06ec538
adding allowShardReordering to SearchRequest
pmpailis Sep 12, 2024
5d42f41
adding tophits to rankquery
pmpailis Sep 16, 2024
ce1c55f
Merge remote-tracking branch 'origin/main' into rework_rrf_to_work_th…
pmpailis Sep 17, 2024
d08161a
updating license
pmpailis Sep 17, 2024
9e1a747
iter
pmpailis Sep 17, 2024
bfb6181
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
pmpailis Sep 17, 2024
c2c63fe
fixing test
pmpailis Sep 17, 2024
4f7b775
Merge branch 'rework_rrf_to_work_through_rewrite_phase' of github.com…
pmpailis Sep 17, 2024
a63dd95
addressing PR comments - removing decoding rank when comparing sort v…
pmpailis Sep 18, 2024
123f996
addressing PR comments - adding rrf_retriever_composition_supported c…
pmpailis Sep 18, 2024
bf15a0e
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
pmpailis Sep 18, 2024
456b1bc
removing RankSort & adding nested clauses to RankDocsQuery
pmpailis Sep 24, 2024
db98014
reverting change to test
pmpailis Sep 24, 2024
986babe
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
pmpailis Sep 24, 2024
d2752e9
iter
pmpailis Sep 24, 2024
b331dc6
iter
pmpailis Sep 24, 2024
620290f
setting setPreFilterShardSize for compound retriever search requests
pmpailis Sep 24, 2024
b5fb4cf
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
elasticmachine Sep 24, 2024
fd540aa
iter
pmpailis Sep 24, 2024
520df49
updating test
pmpailis Sep 25, 2024
77c19ba
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
pmpailis Sep 25, 2024
b90dff8
updating test
pmpailis Sep 25, 2024
ceecfaf
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
elasticmachine Sep 25, 2024
57860c0
updating validation & tests
pmpailis Sep 25, 2024
9dcdfed
Merge branch 'rework_rrf_to_work_through_rewrite_phase' of github.com…
pmpailis Sep 25, 2024
555bb4c
iter
pmpailis Sep 25, 2024
4c20964
Merge remote-tracking branch 'origin/main' into rework_rrf_to_work_th…
pmpailis Sep 25, 2024
89d67d6
addressing PR comments
pmpailis Sep 25, 2024
dd415f2
reworking pagination test for rrf
pmpailis Sep 25, 2024
fd83384
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
elasticmachine Sep 25, 2024
d5478d6
addressing PR comments - part 1
pmpailis Sep 25, 2024
4e7eb4e
addressing PR comments - reworking mutating RRFRankDoc
pmpailis Sep 25, 2024
2366d4c
addressing PR comments - hard fail if tailQuery is null
pmpailis Sep 25, 2024
2c19f2a
Update server/src/test/java/org/elasticsearch/search/retriever/RankDo…
pmpailis Sep 25, 2024
1a9ccdd
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
pmpailis Sep 25, 2024
b623bee
addressing PR comments - adding java docs & updating yml tests to use…
pmpailis Sep 25, 2024
9fdc501
iter
pmpailis Sep 25, 2024
ff05d13
collapsing different yml tests files to a single one
pmpailis Sep 25, 2024
ec9c725
addressing PR comments - adding score validation in yml tests and ens…
pmpailis Sep 26, 2024
885c4b2
addressing PR comments - removing 0 replicas setting
pmpailis Sep 26, 2024
af5ae62
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
elasticmachine Sep 26, 2024
6b1fd8a
adding nested RRF explain support and updating tests
pmpailis Sep 26, 2024
beeab5d
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
elasticmachine Sep 26, 2024
96d2973
Merge branch 'main' into rework_rrf_to_work_through_rewrite_phase
pmpailis Oct 3, 2024
9d1532d
updating highlighting
pmpailis Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions docs/reference/search/rrf.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,12 @@ We have both the ranker's `score` and the `_rank` option to show our top-ranked
"value" : 5,
"relation" : "eq"
},
"max_score" : null,
"max_score" : ...,
"hits" : [
{
"_index" : "example-index",
"_id" : "3",
"_score" : 0.8333334,
"_rank" : 1,
"_source" : {
"integer" : 1,
"vector" : [
Expand All @@ -319,7 +318,6 @@ We have both the ranker's `score` and the `_rank` option to show our top-ranked
"_index" : "example-index",
"_id" : "2",
"_score" : 0.5833334,
"_rank" : 2,
"_source" : {
"integer" : 2,
"vector" : [
Expand All @@ -332,7 +330,6 @@ We have both the ranker's `score` and the `_rank` option to show our top-ranked
"_index" : "example-index",
"_id" : "4",
"_score" : 0.5,
"_rank" : 3,
"_source" : {
"integer" : 2,
"text" : "rrf rrf rrf rrf"
Expand Down Expand Up @@ -499,7 +496,6 @@ Working with the example above, and by adding `explain=true` to the search reque
"_index": "example-index",
"_id": "3",
"_score": 0.8333334,
"_rank": 1,
"_explanation":
{
"value": 0.8333334, <1>
Expand Down Expand Up @@ -608,7 +604,6 @@ The response would now include the named query in the explanation:
"_index": "example-index",
"_id": "3",
"_score": 0.8333334,
"_rank": 1,
"_explanation":
{
"value": 0.8333334,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.NestedSortBuilder;
import org.elasticsearch.search.sort.ScoreSortBuilder;
import org.elasticsearch.search.sort.ShardDocSortField;
import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
Expand Down Expand Up @@ -205,8 +206,8 @@ public void testRankDocsRetrieverBasicWithPagination() {
null
);
// the compound retriever here produces a score for a doc based on the percentage of the queries that it was matched on and
// resolves ties based on actual score, rank, and then the doc (we're forcing 1 shard for consistent results)
// so ideal rank would be: 6, 2, 1, 4, 7, 3 and with pagination, we'd just omit the first result
// resolves ties based on actual score, and then the doc (we're forcing 1 shard for consistent results)
// so ideal rank would be: 6, 2, 1, 3, 4, 7 and with pagination, we'd just omit the first result
source.retriever(
new CompoundRetrieverWithRankDocs(
rankWindowSize,
Expand All @@ -227,9 +228,9 @@ public void testRankDocsRetrieverBasicWithPagination() {
assertThat(resp.getHits().getTotalHits().relation, equalTo(TotalHits.Relation.EQUAL_TO));
assertThat(resp.getHits().getAt(0).getId(), equalTo("doc_2"));
assertThat(resp.getHits().getAt(1).getId(), equalTo("doc_1"));
assertThat(resp.getHits().getAt(2).getId(), equalTo("doc_4"));
assertThat(resp.getHits().getAt(3).getId(), equalTo("doc_7"));
assertThat(resp.getHits().getAt(4).getId(), equalTo("doc_3"));
assertThat(resp.getHits().getAt(2).getId(), equalTo("doc_3"));
Copy link
Contributor Author

@pmpailis pmpailis Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rank has now been removed so we just rely on score and doc

assertThat(resp.getHits().getAt(3).getId(), equalTo("doc_4"));
assertThat(resp.getHits().getAt(4).getId(), equalTo("doc_7"));
});
}

Expand Down Expand Up @@ -267,13 +268,15 @@ public void testRankDocsRetrieverWithAggs() {
)
)
);
source.size(1);
source.aggregation(new TermsAggregationBuilder("topic").field(TOPIC_FIELD));
SearchRequestBuilder req = client().prepareSearch(INDEX).setSource(source);
ElasticsearchAssertions.assertResponse(req, resp -> {
assertNull(resp.pointInTimeId());
assertNotNull(resp.getHits().getTotalHits());
assertThat(resp.getHits().getTotalHits().value, equalTo(1L));
assertThat(resp.getHits().getTotalHits().value, equalTo(5L));
assertThat(resp.getHits().getTotalHits().relation, equalTo(TotalHits.Relation.EQUAL_TO));
assertThat(resp.getHits().getHits().length, equalTo(1));
assertThat(resp.getHits().getAt(0).getId(), equalTo("doc_2"));
assertNotNull(resp.getAggregations());
assertNotNull(resp.getAggregations().get("topic"));
Expand Down Expand Up @@ -307,8 +310,8 @@ public void testRankDocsRetrieverWithCollapse() {
null
);
// the compound retriever here produces a score for a doc based on the percentage of the queries that it was matched on and
// resolves ties based on actual score, rank, and then the doc (we're forcing 1 shard for consistent results)
// so ideal rank would be: 6, 2, 1, 4, 7, 3
// resolves ties based on actual score, and then the doc (we're forcing 1 shard for consistent results)
// so ideal rank would be: 6, 2, 1, 3, 4, 7
// with collapsing on topic field we would have 6, 2, 1, 7
source.retriever(
new CompoundRetrieverWithRankDocs(
Expand Down Expand Up @@ -347,11 +350,7 @@ public void testRankDocsRetrieverWithCollapse() {
});
}

public void testRankDocsRetrieverWithCollapseAndAggs() {
// same as above, but we only want to bring back the top result from each subsearch
// so that would be 1, 2, and 7
// and final rank would be (based on score): 2, 1, 7
// aggs should still account for the same docs as the testRankDocsRetriever test, i.e. all but doc_5
public void testRankDocsRetrieverWithNestedCollapseAndAggs() {
final int rankWindowSize = 10;
SearchSourceBuilder source = new SearchSourceBuilder();
StandardRetrieverBuilder standard0 = new StandardRetrieverBuilder();
Expand All @@ -375,8 +374,8 @@ public void testRankDocsRetrieverWithCollapseAndAggs() {
null
);
// the compound retriever here produces a score for a doc based on the percentage of the queries that it was matched on and
// resolves ties based on actual score, rank, and then the doc (we're forcing 1 shard for consistent results)
// so ideal rank would be: 6, 2, 1, 4, 7, 3
// resolves ties based on actual score, and then the doc (we're forcing 1 shard for consistent results)
// so ideal rank would be: 6, 2, 1, 3, 4, 7
source.retriever(
new CompoundRetrieverWithRankDocs(
rankWindowSize,
Expand All @@ -392,7 +391,7 @@ public void testRankDocsRetrieverWithCollapseAndAggs() {
ElasticsearchAssertions.assertResponse(req, resp -> {
assertNull(resp.pointInTimeId());
assertNotNull(resp.getHits().getTotalHits());
assertThat(resp.getHits().getTotalHits().value, equalTo(5L));
assertThat(resp.getHits().getTotalHits().value, equalTo(6L));
assertThat(resp.getHits().getTotalHits().relation, equalTo(TotalHits.Relation.EQUAL_TO));
assertThat(resp.getHits().getAt(0).getId(), equalTo("doc_6"));
assertNotNull(resp.getAggregations());
Expand Down Expand Up @@ -427,8 +426,8 @@ public void testRankDocsRetrieverWithNestedQuery() {
null
);
// the compound retriever here produces a score for a doc based on the percentage of the queries that it was matched on and
// resolves ties based on actual score, rank, and then the doc (we're forcing 1 shard for consistent results)
// so ideal rank would be: 6, 2, 1, 4, 3, 7
// resolves ties based on actual score, and then the doc (we're forcing 1 shard for consistent results)
// so ideal rank would be: 6, 2, 1, 3, 4, 7
source.retriever(
new CompoundRetrieverWithRankDocs(
rankWindowSize,
Expand Down Expand Up @@ -506,11 +505,11 @@ public void testRankDocsRetrieverMultipleCompoundRetrievers() {
assertThat(resp.getHits().getTotalHits().value, equalTo(6L));
assertThat(resp.getHits().getTotalHits().relation, equalTo(TotalHits.Relation.EQUAL_TO));
assertThat(resp.getHits().getAt(0).getId(), equalTo("doc_4"));
assertThat(resp.getHits().getAt(1).getId(), equalTo("doc_6"));
assertThat(resp.getHits().getAt(1).getId(), equalTo("doc_1"));
assertThat(resp.getHits().getAt(2).getId(), equalTo("doc_2"));
assertThat(resp.getHits().getAt(3).getId(), equalTo("doc_1"));
assertThat(resp.getHits().getAt(4).getId(), equalTo("doc_7"));
assertThat(resp.getHits().getAt(5).getId(), equalTo("doc_3"));
assertThat(resp.getHits().getAt(3).getId(), equalTo("doc_3"));
assertThat(resp.getHits().getAt(4).getId(), equalTo("doc_6"));
assertThat(resp.getHits().getAt(5).getId(), equalTo("doc_7"));
});
}

Expand Down Expand Up @@ -545,9 +544,9 @@ public void testRankDocsRetrieverDifferentNestedSorting() {
assertThat(resp.getHits().getTotalHits().relation, equalTo(TotalHits.Relation.EQUAL_TO));
assertThat(resp.getHits().getAt(0).getId(), equalTo("doc_4"));
assertThat(resp.getHits().getAt(1).getId(), equalTo("doc_1"));
assertThat(resp.getHits().getAt(2).getId(), equalTo("doc_7"));
assertThat(resp.getHits().getAt(2).getId(), equalTo("doc_2"));
assertThat(resp.getHits().getAt(3).getId(), equalTo("doc_6"));
assertThat(resp.getHits().getAt(4).getId(), equalTo("doc_2"));
assertThat(resp.getHits().getAt(4).getId(), equalTo("doc_7"));
});
}

Expand Down Expand Up @@ -673,22 +672,14 @@ private RankDoc[] getRankDocs(SearchResponse searchResponse) {
for (int i = 0; i < size; i++) {
var hit = searchResponse.getHits().getAt(i);
long sortValue = (long) hit.getRawSortValues()[hit.getRawSortValues().length - 1];
int doc = decodeDoc(sortValue);
int shardRequestIndex = decodeShardRequestIndex(sortValue);
int doc = ShardDocSortField.decodeDoc(sortValue);
int shardRequestIndex = ShardDocSortField.decodeShardRequestIndex(sortValue);
docs[i] = new RankDoc(doc, hit.getScore(), shardRequestIndex);
docs[i].rank = i + 1;
}
return docs;
}

public static int decodeDoc(long value) {
return (int) value;
}

public static int decodeShardRequestIndex(long value) {
return (int) (value >> 32);
}

record RankDocAndHitRatio(RankDoc rankDoc, float hitRatio) {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static TransportVersion def(int id) {
public static final TransportVersion ML_TELEMETRY_MEMORY_ADDED = def(8_748_00_0);
public static final TransportVersion ILM_ADD_SEARCHABLE_SNAPSHOT_TOTAL_SHARDS_PER_NODE = def(8_749_00_0);
public static final TransportVersion SEMANTIC_TEXT_SEARCH_INFERENCE_ID = def(8_750_00_0);

public static final TransportVersion RRF_QUERY_REWRITE = def(8_751_00_0);
/*
* STOP! READ THIS FIRST! No, really,
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ private GroupShardsIterator<SearchShardIterator> getIterator(
iter.skip(true);
}
}
if (shouldSortShards(results.minAndMaxes) == false) {
if (false == shouldSortShards(results.minAndMaxes)) {
return shardsIts;
}
FieldSortBuilder fieldSort = FieldSortBuilder.getPrimaryFieldSortOrNull(request.source());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ private void innerRun() throws Exception {
// still use DFS_QUERY_THEN_FETCH, which does not perform the "query and fetch" optimization during the query phase.
final boolean queryAndFetchOptimization = searchPhaseShardResults.length() == 1
&& context.getRequest().hasKnnSearch() == false
&& reducedQueryPhase.queryPhaseRankCoordinatorContext() == null;
&& reducedQueryPhase.queryPhaseRankCoordinatorContext() == null
&& (context.getRequest().source() == null || context.getRequest().source().rankBuilder() == null);
if (queryAndFetchOptimization) {
assert assertConsistentWithQueryAndFetchOptimization();
// query AND fetch optimization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,13 @@ private static SearchHits getHits(
searchHit.setRank(((RankDoc) shardDoc).rank);
searchHit.score(shardDoc.score);
} else if (sortedTopDocs.isSortedByField) {
FieldDoc fieldDoc = (FieldDoc) shardDoc;
searchHit.sortValues(fieldDoc.fields, reducedQueryPhase.sortValueFormats);
if (sortScoreIndex != -1) {
searchHit.score(((Number) fieldDoc.fields[sortScoreIndex]).floatValue());
if (shardDoc instanceof FieldDoc fieldDoc) {
searchHit.sortValues(fieldDoc.fields, reducedQueryPhase.sortValueFormats);
if (sortScoreIndex != -1) {
searchHit.score(((Number) fieldDoc.fields[sortScoreIndex]).floatValue());
}
} else {
throw new IllegalArgumentException("Unsupported ScoreDoc type: " + shardDoc.getClass());
}
} else {
searchHit.score(shardDoc.score);
Expand Down Expand Up @@ -638,7 +641,7 @@ static ReducedQueryPhase reducedQueryPhase(
final SearchProfileResultsBuilder profileBuilder = profileShardResults.isEmpty()
? null
: new SearchProfileResultsBuilder(profileShardResults);
final SortedTopDocs sortedTopDocs;
SortedTopDocs sortedTopDocs;
if (queryPhaseRankCoordinatorContext == null) {
sortedTopDocs = sortDocs(isScrollRequest, bufferedTopDocs, from, size, reducedCompletionSuggestions);
} else {
Expand Down Expand Up @@ -811,7 +814,7 @@ SearchPhaseResults<SearchPhaseResult> newSearchPhaseResults(
int numShards,
Consumer<Exception> onPartialMergeFailure
) {
final int size = request.source() == null || request.source().size() == -1 ? SearchService.DEFAULT_SIZE : request.source().size();
final int size = request.source() == null || request.source().size() == -1 ? DEFAULT_SIZE : request.source().size();
// Use CountOnlyQueryPhaseResultConsumer for requests without aggs, suggest, etc. things only wanting a total count and
// returning no hits
if (size == 0
Expand Down Expand Up @@ -839,7 +842,7 @@ SearchPhaseResults<SearchPhaseResult> newSearchPhaseResults(
public static final class TopDocsStats {
final int trackTotalHitsUpTo;
long totalHits;
private TotalHits.Relation totalHitsRelation;
private Relation totalHitsRelation;
public long fetchHits;
private float maxScore = Float.NEGATIVE_INFINITY;
public boolean timedOut;
Expand Down Expand Up @@ -880,7 +883,7 @@ void add(TopDocsAndMaxScore topDocs, boolean timedOut, Boolean terminatedEarly)
if (trackTotalHitsUpTo != SearchContext.TRACK_TOTAL_HITS_DISABLED) {
totalHits += topDocs.topDocs.totalHits.value;
if (topDocs.topDocs.totalHits.relation == Relation.GREATER_THAN_OR_EQUAL_TO) {
totalHitsRelation = TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO;
totalHitsRelation = Relation.GREATER_THAN_OR_EQUAL_TO;
}
}
fetchHits += topDocs.topDocs.scoreDocs.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ void executeRequest(
});
final SearchSourceBuilder source = original.source();
if (shouldOpenPIT(source)) {
// disabling shard reordering for request
original.setPreFilterShardSize(Integer.MAX_VALUE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to document (in a later PR) and call this out as a known limitation. Indicating that we do not skip serializing to nodes with zero valid results. Clarifying that we won't actually gather any results.

It would also be good to know if this will cause us to fetch metadata in frozen. Serializing to the node and then doing an actual no-op, is ok. But if we actually skip the cluster state information and fetch timestamp metadata, that would be bad.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if we actually skip the cluster state information and fetch timestamp metadata, that would be bad.

Why is that? The min/max timestamp for frozen indices is cached. It's not ideal that we have to skip the can match on the coordinating node but it won't cause any additional I/Os on the frozen tier, just additional back and forth.

openPIT(client, original, searchService.getDefaultKeepAliveInMillis(), listener.delegateFailureAndWrap((delegate, resp) -> {
// We set the keep alive to -1 to indicate that we don't need the pit id in the response.
// This is needed since we delete the pit prior to sending the response so the id doesn't exist anymore.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.lucene.grouping.TopFieldGroups;
import org.elasticsearch.search.retriever.rankdoc.RankDocsSortField;
import org.elasticsearch.search.sort.ShardDocSortField;

import java.io.IOException;
Expand Down Expand Up @@ -553,8 +552,6 @@ private static SortField rewriteMergeSortField(SortField sortField) {
return newSortField;
} else if (sortField.getClass() == ShardDocSortField.class) {
return new SortField(sortField.getField(), SortField.Type.LONG, sortField.getReverse());
} else if (sortField.getClass() == RankDocsSortField.class) {
return new SortField(sortField.getField(), SortField.Type.INT, sortField.getReverse());
} else {
return sortField;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@
import org.elasticsearch.search.retriever.RetrieverParserContext;
import org.elasticsearch.search.retriever.StandardRetrieverBuilder;
import org.elasticsearch.search.retriever.rankdoc.RankDocsQueryBuilder;
import org.elasticsearch.search.retriever.rankdoc.RankDocsSortBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.GeoDistanceSortBuilder;
import org.elasticsearch.search.sort.ScoreSortBuilder;
Expand Down Expand Up @@ -868,7 +867,6 @@ private void registerSorts() {
namedWriteables.add(new NamedWriteableRegistry.Entry(SortBuilder.class, ScoreSortBuilder.NAME, ScoreSortBuilder::new));
namedWriteables.add(new NamedWriteableRegistry.Entry(SortBuilder.class, ScriptSortBuilder.NAME, ScriptSortBuilder::new));
namedWriteables.add(new NamedWriteableRegistry.Entry(SortBuilder.class, FieldSortBuilder.NAME, FieldSortBuilder::new));
namedWriteables.add(new NamedWriteableRegistry.Entry(SortBuilder.class, RankDocsSortBuilder.NAME, RankDocsSortBuilder::new));
}

private static <T> void registerFromPlugin(List<SearchPlugin> plugins, Function<SearchPlugin, List<T>> producer, Consumer<T> consumer) {
Expand Down
Loading