Skip to content

Commit 545ed87

Browse files
committed
Merge remote-tracking branch 'es/6.x' into ccr-6.x
* es/6.x: Move score script context from SearchScript to its own class (#30816) Fix bad version check writing Repository nodes (#30846) Modify state of VerifyRepositoryResponse for bwc (#30762) QA: Fix tribe tests when running default zip Use remote client in TransportFieldCapsAction (#30838) Mute IndexMasterFailoverIT.testMasterFailoverDuringIndexingWithMappingChanges Ensure that ip_range aggregations always return bucket keys. (#30701) Limit user to single concurrent auth per realm (#30794) Security: fix dynamic mapping updates with aliases (#30787) [Tests] Move templated _rank_eval tests (#30679) Move Watcher versioning setting to meta field (#30832) Restore "Add more yaml tests for get alias API " (#30814) Send client headers from TransportClient (#30803) [Docs] Explain incomplete dates in range queries (#30689) Move persistent task registrations to core (#30755) Decouple ClusterStateTaskListener & ClusterApplier (#30809) Packaging: Ensure upgrade_is_oss flag file is always deleted (#30732) Force stable file modes for built packages (#30823)
2 parents 2aa0570 + 619cad9 commit 545ed87

File tree

72 files changed

+1667
-760
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

+1667
-760
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency
1111
import org.gradle.api.tasks.Copy
1212
import org.gradle.api.tasks.Delete
1313
import org.gradle.api.tasks.Exec
14+
import org.gradle.api.tasks.StopExecutionException
1415
import org.gradle.api.tasks.TaskState
1516

1617
import static java.util.Collections.unmodifiableList
@@ -285,8 +286,10 @@ class VagrantTestPlugin implements Plugin<Project> {
285286
dependsOn copyPackagingArchives
286287
doFirst {
287288
project.delete("${archivesDir}/upgrade_is_oss")
289+
if (project.extensions.esvagrant.upgradeFromVersion.before('6.3.0')) {
290+
throw new StopExecutionException("upgrade version is before 6.3.0")
291+
}
288292
}
289-
onlyIf { project.extensions.esvagrant.upgradeFromVersion.onOrAfter('6.3.0') }
290293
file "${archivesDir}/upgrade_is_oss"
291294
contents ''
292295
}

distribution/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
242242
if (it.relativePath.segments[-2] == 'bin') {
243243
// bin files, wherever they are within modules (eg platform specific) should be executable
244244
it.mode = 0755
245+
} else {
246+
it.mode = 0644
245247
}
246248
}
247249
if (oss) {

distribution/packages/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Closure commonPackageConfig(String type, boolean oss) {
122122
}
123123
from(rootProject.projectDir) {
124124
include 'README.textile'
125+
fileMode 0644
125126
}
126127
into('modules') {
127128
with copySpec {
@@ -135,6 +136,11 @@ Closure commonPackageConfig(String type, boolean oss) {
135136
for (int i = segments.length - 2; i > 0 && segments[i] != 'modules'; --i) {
136137
directory('/' + segments[0..i].join('/'), 0755)
137138
}
139+
if (segments[-2] == 'bin') {
140+
fcp.mode = 0755
141+
} else {
142+
fcp.mode = 0644
143+
}
138144
}
139145
}
140146
}
@@ -153,6 +159,7 @@ Closure commonPackageConfig(String type, boolean oss) {
153159
include oss ? 'APACHE-LICENSE-2.0.txt' : 'ELASTIC-LICENSE.txt'
154160
rename { 'LICENSE.txt' }
155161
}
162+
fileMode 0644
156163
}
157164
}
158165

@@ -181,14 +188,17 @@ Closure commonPackageConfig(String type, boolean oss) {
181188
configurationFile '/usr/lib/systemd/system/elasticsearch.service'
182189
into('/usr/lib/tmpfiles.d') {
183190
from "${packagingFiles}/systemd/elasticsearch.conf"
191+
fileMode 0644
184192
}
185193
into('/usr/lib/systemd/system') {
186194
fileType CONFIG | NOREPLACE
187195
from "${packagingFiles}/systemd/elasticsearch.service"
196+
fileMode 0644
188197
}
189198
into('/usr/lib/sysctl.d') {
190199
fileType CONFIG | NOREPLACE
191200
from "${packagingFiles}/systemd/sysctl/elasticsearch.conf"
201+
fileMode 0644
192202
}
193203

194204
// ========= sysV init =========

docs/reference/aggregations/bucket/iprange-aggregation.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ Response:
3737
"ip_ranges": {
3838
"buckets" : [
3939
{
40+
"key": "*-10.0.0.5",
4041
"to": "10.0.0.5",
4142
"doc_count": 10
4243
},
4344
{
45+
"key": "10.0.0.5-*",
4446
"from": "10.0.0.5",
4547
"doc_count": 260
4648
}

docs/reference/query-dsl/range-query.asciidoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ GET _search
109109
--------------------------------------------------
110110
// CONSOLE
111111

112+
Note that if the date misses some of the year, month and day coordinates, the
113+
missing parts are filled with the start of
114+
https://en.wikipedia.org/wiki/Unix_time[unix time], which is January 1st, 1970.
115+
This means, that when e.g. specifying `dd` as the format, a value like `"gte" : 10`
116+
will translate to `1970-01-10T00:00:00.000Z`.
117+
112118
===== Time zone in range queries
113119

114120
Dates can be converted from another timezone to UTC either by specifying the

modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
import org.apache.lucene.expressions.SimpleBindings;
2424
import org.apache.lucene.expressions.js.JavascriptCompiler;
2525
import org.apache.lucene.expressions.js.VariableContext;
26+
import org.apache.lucene.index.LeafReaderContext;
2627
import org.apache.lucene.queries.function.ValueSource;
2728
import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource;
29+
import org.apache.lucene.search.Scorer;
2830
import org.apache.lucene.search.SortField;
2931
import org.elasticsearch.SpecialPermission;
3032
import org.elasticsearch.common.Nullable;
@@ -39,12 +41,14 @@
3941
import org.elasticsearch.script.ClassPermission;
4042
import org.elasticsearch.script.ExecutableScript;
4143
import org.elasticsearch.script.FilterScript;
44+
import org.elasticsearch.script.ScoreScript;
4245
import org.elasticsearch.script.ScriptContext;
4346
import org.elasticsearch.script.ScriptEngine;
4447
import org.elasticsearch.script.ScriptException;
4548
import org.elasticsearch.script.SearchScript;
4649
import org.elasticsearch.search.lookup.SearchLookup;
4750

51+
import java.io.IOException;
4852
import java.security.AccessControlContext;
4953
import java.security.AccessController;
5054
import java.security.PrivilegedAction;
@@ -111,6 +115,9 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE
111115
} else if (context.instanceClazz.equals(FilterScript.class)) {
112116
FilterScript.Factory factory = (p, lookup) -> newFilterScript(expr, lookup, p);
113117
return context.factoryClazz.cast(factory);
118+
} else if (context.instanceClazz.equals(ScoreScript.class)) {
119+
ScoreScript.Factory factory = (p, lookup) -> newScoreScript(expr, lookup, p);
120+
return context.factoryClazz.cast(factory);
114121
}
115122
throw new IllegalArgumentException("expression engine does not know how to handle script context [" + context.name + "]");
116123
}
@@ -260,6 +267,42 @@ public void setDocument(int docid) {
260267
};
261268
};
262269
}
270+
271+
private ScoreScript.LeafFactory newScoreScript(Expression expr, SearchLookup lookup, @Nullable Map<String, Object> vars) {
272+
SearchScript.LeafFactory searchLeafFactory = newSearchScript(expr, lookup, vars);
273+
return new ScoreScript.LeafFactory() {
274+
@Override
275+
public boolean needs_score() {
276+
return searchLeafFactory.needs_score();
277+
}
278+
279+
@Override
280+
public ScoreScript newInstance(LeafReaderContext ctx) throws IOException {
281+
SearchScript script = searchLeafFactory.newInstance(ctx);
282+
return new ScoreScript(vars, lookup, ctx) {
283+
@Override
284+
public double execute() {
285+
return script.runAsDouble();
286+
}
287+
288+
@Override
289+
public void setDocument(int docid) {
290+
script.setDocument(docid);
291+
}
292+
293+
@Override
294+
public void setScorer(Scorer scorer) {
295+
script.setScorer(scorer);
296+
}
297+
298+
@Override
299+
public double get_score() {
300+
return script.getScore();
301+
}
302+
};
303+
}
304+
};
305+
}
263306

264307
/**
265308
* converts a ParseException at compile-time or link-time to a ScriptException

plugins/examples/script-expert-scoring/src/main/java/org/elasticsearch/example/expertscript/ExpertScriptPlugin.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import org.elasticsearch.common.settings.Settings;
3131
import org.elasticsearch.plugins.Plugin;
3232
import org.elasticsearch.plugins.ScriptPlugin;
33+
import org.elasticsearch.script.ScoreScript;
3334
import org.elasticsearch.script.ScriptContext;
3435
import org.elasticsearch.script.ScriptEngine;
35-
import org.elasticsearch.script.SearchScript;
3636

3737
/**
3838
* An example script plugin that adds a {@link ScriptEngine} implementing expert scoring.
@@ -54,12 +54,12 @@ public String getType() {
5454

5555
@Override
5656
public <T> T compile(String scriptName, String scriptSource, ScriptContext<T> context, Map<String, String> params) {
57-
if (context.equals(SearchScript.SCRIPT_SCORE_CONTEXT) == false) {
57+
if (context.equals(ScoreScript.CONTEXT) == false) {
5858
throw new IllegalArgumentException(getType() + " scripts cannot be used for context [" + context.name + "]");
5959
}
6060
// we use the script "source" as the script identifier
6161
if ("pure_df".equals(scriptSource)) {
62-
SearchScript.Factory factory = (p, lookup) -> new SearchScript.LeafFactory() {
62+
ScoreScript.Factory factory = (p, lookup) -> new ScoreScript.LeafFactory() {
6363
final String field;
6464
final String term;
6565
{
@@ -74,18 +74,18 @@ public <T> T compile(String scriptName, String scriptSource, ScriptContext<T> co
7474
}
7575

7676
@Override
77-
public SearchScript newInstance(LeafReaderContext context) throws IOException {
77+
public ScoreScript newInstance(LeafReaderContext context) throws IOException {
7878
PostingsEnum postings = context.reader().postings(new Term(field, term));
7979
if (postings == null) {
8080
// the field and/or term don't exist in this segment, so always return 0
81-
return new SearchScript(p, lookup, context) {
81+
return new ScoreScript(p, lookup, context) {
8282
@Override
83-
public double runAsDouble() {
83+
public double execute() {
8484
return 0.0d;
8585
}
8686
};
8787
}
88-
return new SearchScript(p, lookup, context) {
88+
return new ScoreScript(p, lookup, context) {
8989
int currentDocid = -1;
9090
@Override
9191
public void setDocument(int docid) {
@@ -100,7 +100,7 @@ public void setDocument(int docid) {
100100
currentDocid = docid;
101101
}
102102
@Override
103-
public double runAsDouble() {
103+
public double execute() {
104104
if (postings.docID() != currentDocid) {
105105
// advance moved past the current doc, so this doc has no occurrences of the term
106106
return 0.0d;

qa/smoke-test-rank-eval-with-mustache/build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,3 @@ dependencies {
3131
* and will be fixed later.
3232
* Tracked by https://github.com/elastic/elasticsearch/issues/30628
3333
*/
34-
if ("zip".equals(integTestCluster.distribution)) {
35-
integTestRunner.enabled = false
36-
}

0 commit comments

Comments
 (0)