Skip to content

Commit ad9238e

Browse files
committed
merging main
2 parents d85b4d7 + 4f506d4 commit ad9238e

File tree

72 files changed

+1121
-332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1121
-332
lines changed

docs/changelog/126641.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 126641
2+
summary: Push more `==`s on text fields to lucene
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorMatchedSlotSubFetchPhase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void process(HitContext hitContext) throws IOException {
100100
IntStream slots = convertTopDocsToSlots(topDocs, pc.rootDocsBySlot);
101101
// _percolator_document_slot fields are document fields and should be under "fields" section in a hit
102102
List<Object> docSlots = slots.boxed().collect(Collectors.toList());
103-
hitContext.hit().setDocumentField(fieldName, new DocumentField(fieldName, docSlots));
103+
hitContext.hit().setDocumentField(new DocumentField(fieldName, docSlots));
104104

105105
// Add info what sub-queries of percolator query matched this each percolated document
106106
if (fetchContext.getSearchExecutionContext().hasNamedQueries()) {
@@ -120,7 +120,7 @@ public void process(HitContext hitContext) throws IOException {
120120
matchedQueries.add(match.getName());
121121
}
122122
String matchedFieldName = fieldName + "_" + docSlots.get(i) + "_matched_queries";
123-
hitContext.hit().setDocumentField(matchedFieldName, new DocumentField(matchedFieldName, matchedQueries));
123+
hitContext.hit().setDocumentField(new DocumentField(matchedFieldName, matchedQueries));
124124
}
125125
}
126126
}

muted-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,12 @@ tests:
438438
- class: org.elasticsearch.xpack.esql.plugin.DataNodeRequestSenderTests
439439
method: testRetryOnlyMovedShards
440440
issue: https://github.com/elastic/elasticsearch/issues/127168
441+
- class: org.elasticsearch.xpack.esql.plugin.DataNodeRequestSenderIT
442+
method: testSearchWhileRelocating
443+
issue: https://github.com/elastic/elasticsearch/issues/127188
444+
- class: org.elasticsearch.synonyms.SynonymsManagementAPIServiceIT
445+
method: testUpdateRuleWithMaxSynonyms
446+
issue: https://github.com/elastic/elasticsearch/issues/127195
441447

442448
# Examples:
443449
#

server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,8 +1327,7 @@ public void setNextReader(LeafReaderContext ctx) {
13271327
public void process(FetchSubPhase.HitContext hitContext) {
13281328
leafSearchLookup.setDocument(hitContext.docId());
13291329
FieldLookup fieldLookup = leafSearchLookup.fields().get("text");
1330-
hitContext.hit()
1331-
.setDocumentField("text_stored_lookup", new DocumentField("text_stored_lookup", fieldLookup.getValues()));
1330+
hitContext.hit().setDocumentField(new DocumentField("text_stored_lookup", fieldLookup.getValues()));
13321331
}
13331332

13341333
@Override

server/src/internalClusterTest/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private void hitExecute(FetchContext context, HitContext hitContext) throws IOEx
137137
DocumentField hitField = hitContext.hit().getFields().get(NAME);
138138
if (hitField == null) {
139139
hitField = new DocumentField(NAME, new ArrayList<>(1));
140-
hitContext.hit().setDocumentField(NAME, hitField);
140+
hitContext.hit().setDocumentField(hitField);
141141
}
142142
Terms terms = hitContext.reader().termVectors().get(hitContext.docId(), field);
143143
if (terms != null) {

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ static TransportVersion def(int id) {
233233
public static final TransportVersion SEARCH_INCREMENTAL_TOP_DOCS_NULL = def(9_058_0_00);
234234
public static final TransportVersion COMPRESS_DELAYABLE_WRITEABLE = def(9_059_0_00);
235235
public static final TransportVersion SYNONYMS_REFRESH_PARAM = def(9_060_0_00);
236-
public static final TransportVersion SETTINGS_IN_DATA_STREAMS = def(9_061_00_0);
236+
public static final TransportVersion DOC_FIELDS_AS_LIST = def(9_061_0_00);
237+
public static final TransportVersion SETTINGS_IN_DATA_STREAMS = def(9_062_00_0);
237238

238239
/*
239240
* STOP! READ THIS FIRST! No, really,

server/src/main/java/org/elasticsearch/common/document/DocumentField.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Collections;
2525
import java.util.Iterator;
2626
import java.util.List;
27+
import java.util.Map;
2728
import java.util.Objects;
2829

2930
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
@@ -70,6 +71,15 @@ public DocumentField(String name, List<Object> values, List<Object> ignoredValue
7071
: "DocumentField can't have both lookup fields and values";
7172
}
7273

74+
/**
75+
* Read map of document fields written via {@link StreamOutput#writeMapValues(Map)}.
76+
* @param in stream input
77+
* @return map of {@link DocumentField} keyed by {@link DocumentField#getName()}
78+
*/
79+
public static Map<String, DocumentField> readFieldsFromMapValues(StreamInput in) throws IOException {
80+
return in.readMapValues(DocumentField::new, DocumentField::getName);
81+
}
82+
7383
/**
7484
* The name of the field.
7585
*/

server/src/main/java/org/elasticsearch/index/get/GetResult.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public GetResult(StreamInput in) throws IOException {
7474
if (source.length() == 0) {
7575
source = null;
7676
}
77-
documentFields = in.readMapValues(DocumentField::new, DocumentField::getName);
78-
metaFields = in.readMapValues(DocumentField::new, DocumentField::getName);
77+
documentFields = DocumentField.readFieldsFromMapValues(in);
78+
metaFields = DocumentField.readFieldsFromMapValues(in);
7979
} else {
8080
metaFields = Collections.emptyMap();
8181
documentFields = Collections.emptyMap();

server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,21 @@ public boolean canUseSyntheticSourceDelegateForQuerying() {
983983
&& syntheticSourceDelegate.isIndexed();
984984
}
985985

986+
/**
987+
* Returns true if the delegate sub-field can be used for querying only (ie. isIndexed must be true)
988+
*/
989+
public boolean canUseSyntheticSourceDelegateForQueryingEquality(String str) {
990+
if (syntheticSourceDelegate == null
991+
// Can't push equality to an index if there isn't an index
992+
|| syntheticSourceDelegate.isIndexed() == false
993+
// ESQL needs docs values to push equality
994+
|| syntheticSourceDelegate.hasDocValues() == false) {
995+
return false;
996+
}
997+
// Can't push equality if the field we're checking for is so big we'd ignore it.
998+
return str.length() <= syntheticSourceDelegate.ignoreAbove();
999+
}
1000+
9861001
@Override
9871002
public BlockLoader blockLoader(BlockLoaderContext blContext) {
9881003
if (canUseSyntheticSourceDelegateForLoading()) {

server/src/main/java/org/elasticsearch/index/mapper/TimeSeriesIdFieldMapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ public IndexFieldData.Builder fielddataBuilder(FieldDataContext fieldDataContext
132132
public Query termQuery(Object value, SearchExecutionContext context) {
133133
throw new IllegalArgumentException("[" + NAME + "] is not searchable");
134134
}
135+
136+
@Override
137+
public BlockLoader blockLoader(BlockLoaderContext blContext) {
138+
return new BlockDocValuesReader.BytesRefsFromOrdsBlockLoader(name());
139+
}
135140
}
136141

137142
private final boolean useDocValuesSkipper;

0 commit comments

Comments
 (0)