mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-16 18:04:52 +00:00
Merge pull request #13439 from rmuir/1702090
upgrade lucene to r1702265
This commit is contained in:
commit
e988a9edc6
@ -58,28 +58,28 @@ public class CustomFieldQuery extends FieldQuery {
|
||||
}
|
||||
|
||||
@Override
|
||||
void flatten(Query sourceQuery, IndexReader reader, Collection<Query> flatQueries) throws IOException {
|
||||
void flatten(Query sourceQuery, IndexReader reader, Collection<Query> flatQueries, float boost) throws IOException {
|
||||
if (sourceQuery instanceof SpanTermQuery) {
|
||||
super.flatten(new TermQuery(((SpanTermQuery) sourceQuery).getTerm()), reader, flatQueries);
|
||||
super.flatten(new TermQuery(((SpanTermQuery) sourceQuery).getTerm()), reader, flatQueries, boost);
|
||||
} else if (sourceQuery instanceof ConstantScoreQuery) {
|
||||
flatten(((ConstantScoreQuery) sourceQuery).getQuery(), reader, flatQueries);
|
||||
flatten(((ConstantScoreQuery) sourceQuery).getQuery(), reader, flatQueries, boost);
|
||||
} else if (sourceQuery instanceof FunctionScoreQuery) {
|
||||
flatten(((FunctionScoreQuery) sourceQuery).getSubQuery(), reader, flatQueries);
|
||||
flatten(((FunctionScoreQuery) sourceQuery).getSubQuery(), reader, flatQueries, boost);
|
||||
} else if (sourceQuery instanceof FilteredQuery) {
|
||||
flatten(((FilteredQuery) sourceQuery).getQuery(), reader, flatQueries);
|
||||
flatten(((FilteredQuery) sourceQuery).getQuery(), reader, flatQueries, boost);
|
||||
flatten(((FilteredQuery) sourceQuery).getFilter(), reader, flatQueries);
|
||||
} else if (sourceQuery instanceof MultiPhrasePrefixQuery) {
|
||||
flatten(sourceQuery.rewrite(reader), reader, flatQueries);
|
||||
flatten(sourceQuery.rewrite(reader), reader, flatQueries, boost);
|
||||
} else if (sourceQuery instanceof FiltersFunctionScoreQuery) {
|
||||
flatten(((FiltersFunctionScoreQuery) sourceQuery).getSubQuery(), reader, flatQueries);
|
||||
flatten(((FiltersFunctionScoreQuery) sourceQuery).getSubQuery(), reader, flatQueries, boost);
|
||||
} else if (sourceQuery instanceof MultiPhraseQuery) {
|
||||
MultiPhraseQuery q = ((MultiPhraseQuery) sourceQuery);
|
||||
convertMultiPhraseQuery(0, new int[q.getTermArrays().size()], q, q.getTermArrays(), q.getPositions(), reader, flatQueries);
|
||||
} else if (sourceQuery instanceof BlendedTermQuery) {
|
||||
final BlendedTermQuery blendedTermQuery = (BlendedTermQuery) sourceQuery;
|
||||
flatten(blendedTermQuery.rewrite(reader), reader, flatQueries);
|
||||
flatten(blendedTermQuery.rewrite(reader), reader, flatQueries, boost);
|
||||
} else {
|
||||
super.flatten(sourceQuery, reader, flatQueries);
|
||||
super.flatten(sourceQuery, reader, flatQueries, boost);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class CustomFieldQuery extends FieldQuery {
|
||||
if (numTerms > 16) {
|
||||
for (Term[] currentPosTerm : terms) {
|
||||
for (Term term : currentPosTerm) {
|
||||
super.flatten(new TermQuery(term), reader, flatQueries);
|
||||
super.flatten(new TermQuery(term), reader, flatQueries, orig.getBoost());
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -111,7 +111,7 @@ public class CustomFieldQuery extends FieldQuery {
|
||||
}
|
||||
PhraseQuery query = queryBuilder.build();
|
||||
query.setBoost(orig.getBoost());
|
||||
this.flatten(query, reader, flatQueries);
|
||||
this.flatten(query, reader, flatQueries, orig.getBoost());
|
||||
} else {
|
||||
Term[] t = terms.get(currentPos);
|
||||
for (int i = 0; i < t.length; i++) {
|
||||
@ -127,7 +127,7 @@ public class CustomFieldQuery extends FieldQuery {
|
||||
return;
|
||||
}
|
||||
if (sourceFilter instanceof QueryWrapperFilter) {
|
||||
flatten(((QueryWrapperFilter) sourceFilter).getQuery(), reader, flatQueries);
|
||||
flatten(((QueryWrapperFilter) sourceFilter).getQuery(), reader, flatQueries, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.FileVisitResult;
|
||||
@ -70,21 +71,43 @@ public class JarHell {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the current classloader for duplicate classes
|
||||
* Checks the current classpath for duplicate classes
|
||||
* @throws IllegalStateException if jar hell was found
|
||||
*/
|
||||
public static void checkJarHell() throws Exception {
|
||||
ClassLoader loader = JarHell.class.getClassLoader();
|
||||
if (loader instanceof URLClassLoader == false) {
|
||||
return;
|
||||
}
|
||||
ESLogger logger = Loggers.getLogger(JarHell.class);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("java.class.path: {}", System.getProperty("java.class.path"));
|
||||
logger.debug("sun.boot.class.path: {}", System.getProperty("sun.boot.class.path"));
|
||||
logger.debug("classloader urls: {}", Arrays.toString(((URLClassLoader)loader).getURLs()));
|
||||
if (loader instanceof URLClassLoader ) {
|
||||
logger.debug("classloader urls: {}", Arrays.toString(((URLClassLoader)loader).getURLs()));
|
||||
}
|
||||
}
|
||||
checkJarHell(((URLClassLoader) loader).getURLs());
|
||||
checkJarHell(parseClassPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the classpath into a set of URLs
|
||||
*/
|
||||
@SuppressForbidden(reason = "resolves against CWD because that is how classpaths work")
|
||||
public static URL[] parseClassPath() {
|
||||
String elements[] = System.getProperty("java.class.path").split(System.getProperty("path.separator"));
|
||||
URL urlElements[] = new URL[elements.length];
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
String element = elements[i];
|
||||
// empty classpath element behaves like CWD.
|
||||
if (element.isEmpty()) {
|
||||
element = System.getProperty("user.dir");
|
||||
}
|
||||
try {
|
||||
urlElements[i] = PathUtils.get(element).toUri().toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
// should not happen, as we use the filesystem API
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return urlElements;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,6 @@ import org.elasticsearch.env.Environment;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.AccessMode;
|
||||
import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.Files;
|
||||
@ -121,8 +120,8 @@ final class Security {
|
||||
private static final Map<Pattern,String> SPECIAL_JARS;
|
||||
static {
|
||||
Map<Pattern,String> m = new IdentityHashMap<>();
|
||||
m.put(Pattern.compile(".*lucene-core-.*\\.jar$"), "es.security.jar.lucene.core");
|
||||
m.put(Pattern.compile(".*securemock-.*\\.jar$"), "es.security.jar.elasticsearch.securemock");
|
||||
m.put(Pattern.compile(".*lucene-core-.*\\.jar$"), "es.security.jar.lucene.core");
|
||||
m.put(Pattern.compile(".*securemock-.*\\.jar$"), "es.security.jar.elasticsearch.securemock");
|
||||
SPECIAL_JARS = Collections.unmodifiableMap(m);
|
||||
}
|
||||
|
||||
@ -133,27 +132,21 @@ final class Security {
|
||||
*/
|
||||
@SuppressForbidden(reason = "proper use of URL")
|
||||
static void setCodebaseProperties() {
|
||||
ClassLoader loader = Security.class.getClassLoader();
|
||||
if (loader instanceof URLClassLoader) {
|
||||
for (URL url : ((URLClassLoader)loader).getURLs()) {
|
||||
for (Map.Entry<Pattern,String> e : SPECIAL_JARS.entrySet()) {
|
||||
if (e.getKey().matcher(url.getPath()).matches()) {
|
||||
String prop = e.getValue();
|
||||
if (System.getProperty(prop) != null) {
|
||||
throw new IllegalStateException("property: " + prop + " is unexpectedly set: " + System.getProperty(prop));
|
||||
}
|
||||
System.setProperty(prop, url.toString());
|
||||
for (URL url : JarHell.parseClassPath()) {
|
||||
for (Map.Entry<Pattern,String> e : SPECIAL_JARS.entrySet()) {
|
||||
if (e.getKey().matcher(url.getPath()).matches()) {
|
||||
String prop = e.getValue();
|
||||
if (System.getProperty(prop) != null) {
|
||||
throw new IllegalStateException("property: " + prop + " is unexpectedly set: " + System.getProperty(prop));
|
||||
}
|
||||
System.setProperty(prop, url.toString());
|
||||
}
|
||||
}
|
||||
for (String prop : SPECIAL_JARS.values()) {
|
||||
if (System.getProperty(prop) == null) {
|
||||
System.setProperty(prop, "file:/dev/null"); // no chance to be interpreted as "all"
|
||||
}
|
||||
}
|
||||
for (String prop : SPECIAL_JARS.values()) {
|
||||
if (System.getProperty(prop) == null) {
|
||||
System.setProperty(prop, "file:/dev/null"); // no chance to be interpreted as "all"
|
||||
}
|
||||
} else {
|
||||
// we could try to parse the classpath or something, but screw it for now.
|
||||
throw new UnsupportedOperationException("Unsupported system classloader type: " + loader.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,9 @@ public final class AllTermQuery extends Query {
|
||||
|
||||
@Override
|
||||
public Query rewrite(IndexReader reader) throws IOException {
|
||||
if (getBoost() != 1f) {
|
||||
return super.rewrite(reader);
|
||||
}
|
||||
boolean fieldExists = false;
|
||||
boolean hasPayloads = false;
|
||||
for (LeafReaderContext context : reader.leaves()) {
|
||||
@ -98,7 +101,7 @@ public final class AllTermQuery extends Query {
|
||||
final CollectionStatistics collectionStats = searcher.collectionStatistics(term.field());
|
||||
final TermStatistics termStats = searcher.termStatistics(term, termStates);
|
||||
final Similarity similarity = searcher.getSimilarity(needsScores);
|
||||
final SimWeight stats = similarity.computeWeight(getBoost(), collectionStats, termStats);
|
||||
final SimWeight stats = similarity.computeWeight(collectionStats, termStats);
|
||||
return new Weight(this) {
|
||||
|
||||
@Override
|
||||
|
@ -120,6 +120,9 @@ public class MultiPhrasePrefixQuery extends Query {
|
||||
|
||||
@Override
|
||||
public Query rewrite(IndexReader reader) throws IOException {
|
||||
if (getBoost() != 1.0F) {
|
||||
return super.rewrite(reader);
|
||||
}
|
||||
if (termArrays.isEmpty()) {
|
||||
return new MatchNoDocsQuery();
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ import org.apache.lucene.search.Explanation;
|
||||
public enum CombineFunction {
|
||||
MULT {
|
||||
@Override
|
||||
public float combine(double queryBoost, double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(queryBoost * queryScore * Math.min(funcScore, maxBoost));
|
||||
public float combine(double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(queryScore * Math.min(funcScore, maxBoost));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -34,21 +34,20 @@ public enum CombineFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Explanation explain(float queryBoost, Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
float score = queryBoost * Math.min(funcExpl.getValue(), maxBoost) * queryExpl.getValue();
|
||||
public Explanation explain(Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
Explanation boostExpl = Explanation.match(maxBoost, "maxBoost");
|
||||
Explanation minExpl = Explanation.match(
|
||||
Math.min(funcExpl.getValue(), maxBoost),
|
||||
"min of:",
|
||||
funcExpl, boostExpl);
|
||||
return Explanation.match(score, "function score, product of:",
|
||||
queryExpl, minExpl, Explanation.match(queryBoost, "queryBoost"));
|
||||
return Explanation.match(queryExpl.getValue() * minExpl.getValue(),
|
||||
"function score, product of:", queryExpl, minExpl);
|
||||
}
|
||||
},
|
||||
REPLACE {
|
||||
@Override
|
||||
public float combine(double queryBoost, double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(queryBoost * Math.min(funcScore, maxBoost));
|
||||
public float combine(double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(Math.min(funcScore, maxBoost));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,22 +56,19 @@ public enum CombineFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Explanation explain(float queryBoost, Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
float score = queryBoost * Math.min(funcExpl.getValue(), maxBoost);
|
||||
public Explanation explain(Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
Explanation boostExpl = Explanation.match(maxBoost, "maxBoost");
|
||||
Explanation minExpl = Explanation.match(
|
||||
return Explanation.match(
|
||||
Math.min(funcExpl.getValue(), maxBoost),
|
||||
"min of:",
|
||||
funcExpl, boostExpl);
|
||||
return Explanation.match(score, "function score, product of:",
|
||||
minExpl, Explanation.match(queryBoost, "queryBoost"));
|
||||
}
|
||||
|
||||
},
|
||||
SUM {
|
||||
@Override
|
||||
public float combine(double queryBoost, double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(queryBoost * (queryScore + Math.min(funcScore, maxBoost)));
|
||||
public float combine(double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(queryScore + Math.min(funcScore, maxBoost));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,21 +77,18 @@ public enum CombineFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Explanation explain(float queryBoost, Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
float score = queryBoost * (Math.min(funcExpl.getValue(), maxBoost) + queryExpl.getValue());
|
||||
public Explanation explain(Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
Explanation minExpl = Explanation.match(Math.min(funcExpl.getValue(), maxBoost), "min of:",
|
||||
funcExpl, Explanation.match(maxBoost, "maxBoost"));
|
||||
Explanation sumExpl = Explanation.match(Math.min(funcExpl.getValue(), maxBoost) + queryExpl.getValue(), "sum of",
|
||||
return Explanation.match(Math.min(funcExpl.getValue(), maxBoost) + queryExpl.getValue(), "sum of",
|
||||
queryExpl, minExpl);
|
||||
return Explanation.match(score, "function score, product of:",
|
||||
sumExpl, Explanation.match(queryBoost, "queryBoost"));
|
||||
}
|
||||
|
||||
},
|
||||
AVG {
|
||||
@Override
|
||||
public float combine(double queryBoost, double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat((queryBoost * (Math.min(funcScore, maxBoost) + queryScore) / 2.0));
|
||||
public float combine(double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat((Math.min(funcScore, maxBoost) + queryScore) / 2.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,22 +97,19 @@ public enum CombineFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Explanation explain(float queryBoost, Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
float score = toFloat(queryBoost * (queryExpl.getValue() + Math.min(funcExpl.getValue(), maxBoost)) / 2.0);
|
||||
public Explanation explain(Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
Explanation minExpl = Explanation.match(Math.min(funcExpl.getValue(), maxBoost), "min of:",
|
||||
funcExpl, Explanation.match(maxBoost, "maxBoost"));
|
||||
Explanation avgExpl = Explanation.match(
|
||||
return Explanation.match(
|
||||
toFloat((Math.min(funcExpl.getValue(), maxBoost) + queryExpl.getValue()) / 2.0), "avg of",
|
||||
queryExpl, minExpl);
|
||||
return Explanation.match(score, "function score, product of:",
|
||||
avgExpl, Explanation.match(queryBoost, "queryBoost"));
|
||||
}
|
||||
|
||||
},
|
||||
MIN {
|
||||
@Override
|
||||
public float combine(double queryBoost, double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(queryBoost * Math.min(queryScore, Math.min(funcScore, maxBoost)));
|
||||
public float combine(double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(Math.min(queryScore, Math.min(funcScore, maxBoost)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -128,23 +118,20 @@ public enum CombineFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Explanation explain(float queryBoost, Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
float score = toFloat(queryBoost * Math.min(queryExpl.getValue(), Math.min(funcExpl.getValue(), maxBoost)));
|
||||
public Explanation explain(Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
Explanation innerMinExpl = Explanation.match(
|
||||
Math.min(funcExpl.getValue(), maxBoost), "min of:",
|
||||
funcExpl, Explanation.match(maxBoost, "maxBoost"));
|
||||
Explanation outerMinExpl = Explanation.match(
|
||||
return Explanation.match(
|
||||
Math.min(Math.min(funcExpl.getValue(), maxBoost), queryExpl.getValue()), "min of",
|
||||
queryExpl, innerMinExpl);
|
||||
return Explanation.match(score, "function score, product of:",
|
||||
outerMinExpl, Explanation.match(queryBoost, "queryBoost"));
|
||||
}
|
||||
|
||||
},
|
||||
MAX {
|
||||
@Override
|
||||
public float combine(double queryBoost, double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(queryBoost * (Math.max(queryScore, Math.min(funcScore, maxBoost))));
|
||||
public float combine(double queryScore, double funcScore, double maxBoost) {
|
||||
return toFloat(Math.max(queryScore, Math.min(funcScore, maxBoost)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -153,21 +140,18 @@ public enum CombineFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Explanation explain(float queryBoost, Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
float score = toFloat(queryBoost * Math.max(queryExpl.getValue(), Math.min(funcExpl.getValue(), maxBoost)));
|
||||
public Explanation explain(Explanation queryExpl, Explanation funcExpl, float maxBoost) {
|
||||
Explanation innerMinExpl = Explanation.match(
|
||||
Math.min(funcExpl.getValue(), maxBoost), "min of:",
|
||||
funcExpl, Explanation.match(maxBoost, "maxBoost"));
|
||||
Explanation outerMaxExpl = Explanation.match(
|
||||
return Explanation.match(
|
||||
Math.max(Math.min(funcExpl.getValue(), maxBoost), queryExpl.getValue()), "max of:",
|
||||
queryExpl, innerMinExpl);
|
||||
return Explanation.match(score, "function score, product of:",
|
||||
outerMaxExpl, Explanation.match(queryBoost, "queryBoost"));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public abstract float combine(double queryBoost, double queryScore, double funcScore, double maxBoost);
|
||||
public abstract float combine(double queryScore, double funcScore, double maxBoost);
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
@ -181,5 +165,5 @@ public enum CombineFunction {
|
||||
return Double.compare(floatVersion, input) == 0 || input == 0.0d ? 0 : 1.d - (floatVersion) / input;
|
||||
}
|
||||
|
||||
public abstract Explanation explain(float queryBoost, Explanation queryExpl, Explanation funcExpl, float maxBoost);
|
||||
public abstract Explanation explain(Explanation queryExpl, Explanation funcExpl, float maxBoost);
|
||||
}
|
||||
|
@ -21,13 +21,11 @@ package org.elasticsearch.common.lucene.search.function;
|
||||
|
||||
import org.apache.lucene.search.Scorer;
|
||||
import org.apache.lucene.search.Weight;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
abstract class CustomBoostFactorScorer extends Scorer {
|
||||
|
||||
final float subQueryBoost;
|
||||
final Scorer scorer;
|
||||
final float maxBoost;
|
||||
final CombineFunction scoreCombiner;
|
||||
@ -43,7 +41,6 @@ abstract class CustomBoostFactorScorer extends Scorer {
|
||||
} else {
|
||||
nextDoc = new MinScoreNextDoc();
|
||||
}
|
||||
this.subQueryBoost = w.getQuery().getBoost();
|
||||
this.scorer = scorer;
|
||||
this.maxBoost = maxBoost;
|
||||
this.scoreCombiner = scoreCombiner;
|
||||
|
@ -114,6 +114,9 @@ public class FiltersFunctionScoreQuery extends Query {
|
||||
|
||||
@Override
|
||||
public Query rewrite(IndexReader reader) throws IOException {
|
||||
if (getBoost() != 1.0F) {
|
||||
return super.rewrite(reader);
|
||||
}
|
||||
Query newQ = subQuery.rewrite(reader);
|
||||
if (newQ == subQuery)
|
||||
return this;
|
||||
@ -158,14 +161,12 @@ public class FiltersFunctionScoreQuery extends Query {
|
||||
|
||||
@Override
|
||||
public float getValueForNormalization() throws IOException {
|
||||
float sum = subQueryWeight.getValueForNormalization();
|
||||
sum *= getBoost() * getBoost();
|
||||
return sum;
|
||||
return subQueryWeight.getValueForNormalization();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void normalize(float norm, float topLevelBoost) {
|
||||
subQueryWeight.normalize(norm, topLevelBoost * getBoost());
|
||||
public void normalize(float norm, float boost) {
|
||||
subQueryWeight.normalize(norm, boost);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -219,10 +220,7 @@ public class FiltersFunctionScoreQuery extends Query {
|
||||
}
|
||||
}
|
||||
if (filterExplanations.size() == 0) {
|
||||
float sc = getBoost() * subQueryExpl.getValue();
|
||||
return Explanation.match(sc, "function score, no filter match, product of:",
|
||||
subQueryExpl,
|
||||
Explanation.match(getBoost(), "queryBoost"));
|
||||
return subQueryExpl;
|
||||
}
|
||||
|
||||
// Second: Compute the factor that would have been computed by the
|
||||
@ -266,7 +264,7 @@ public class FiltersFunctionScoreQuery extends Query {
|
||||
CombineFunction.toFloat(factor),
|
||||
"function score, score mode [" + scoreMode.toString().toLowerCase(Locale.ROOT) + "]",
|
||||
filterExplanations);
|
||||
return combineFunction.explain(getBoost(), subQueryExpl, factorExplanation, maxBoost);
|
||||
return combineFunction.explain(subQueryExpl, factorExplanation, maxBoost);
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,7 +346,7 @@ public class FiltersFunctionScoreQuery extends Query {
|
||||
}
|
||||
}
|
||||
}
|
||||
return scoreCombiner.combine(subQueryBoost, subQueryScore, factor, maxBoost);
|
||||
return scoreCombiner.combine(subQueryScore, factor, maxBoost);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,9 @@ public class FunctionScoreQuery extends Query {
|
||||
|
||||
@Override
|
||||
public Query rewrite(IndexReader reader) throws IOException {
|
||||
if (getBoost() != 1.0F) {
|
||||
return super.rewrite(reader);
|
||||
}
|
||||
Query newQ = subQuery.rewrite(reader);
|
||||
if (newQ == subQuery) {
|
||||
return this;
|
||||
@ -117,14 +120,12 @@ public class FunctionScoreQuery extends Query {
|
||||
|
||||
@Override
|
||||
public float getValueForNormalization() throws IOException {
|
||||
float sum = subQueryWeight.getValueForNormalization();
|
||||
sum *= getBoost() * getBoost();
|
||||
return sum;
|
||||
return subQueryWeight.getValueForNormalization();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void normalize(float norm, float topLevelBoost) {
|
||||
subQueryWeight.normalize(norm, topLevelBoost * getBoost());
|
||||
public void normalize(float norm, float boost) {
|
||||
subQueryWeight.normalize(norm, boost);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -148,7 +149,7 @@ public class FunctionScoreQuery extends Query {
|
||||
}
|
||||
if (function != null) {
|
||||
Explanation functionExplanation = function.getLeafScoreFunction(context).explainScore(doc, subQueryExpl);
|
||||
return combineFunction.explain(getBoost(), subQueryExpl, functionExplanation, maxBoost);
|
||||
return combineFunction.explain(subQueryExpl, functionExplanation, maxBoost);
|
||||
} else {
|
||||
return subQueryExpl;
|
||||
}
|
||||
@ -174,9 +175,9 @@ public class FunctionScoreQuery extends Query {
|
||||
// are needed
|
||||
float score = needsScores ? scorer.score() : 0f;
|
||||
if (function == null) {
|
||||
return subQueryBoost * score;
|
||||
return score;
|
||||
} else {
|
||||
return scoreCombiner.combine(subQueryBoost, score,
|
||||
return scoreCombiner.combine(score,
|
||||
function.score(scorer.docID(), score), maxBoost);
|
||||
}
|
||||
}
|
||||
|
@ -219,6 +219,9 @@ public class DateFieldMapper extends NumberFieldMapper {
|
||||
|
||||
@Override
|
||||
public Query rewrite(IndexReader reader) throws IOException {
|
||||
if (getBoost() != 1.0F) {
|
||||
return super.rewrite(reader);
|
||||
}
|
||||
return innerRangeQuery(lowerTerm, upperTerm, includeLower, includeUpper, timeZone, forcedDateParser);
|
||||
}
|
||||
|
||||
|
@ -209,9 +209,12 @@ public class HasChildQueryParser implements QueryParser {
|
||||
|
||||
@Override
|
||||
public Query rewrite(IndexReader reader) throws IOException {
|
||||
if (getBoost() != 1.0F) {
|
||||
return super.rewrite(reader);
|
||||
}
|
||||
String joinField = ParentFieldMapper.joinField(parentType);
|
||||
IndexSearcher indexSearcher = new IndexSearcher(reader);
|
||||
indexSearcher.setQueryCache(null);
|
||||
String joinField = ParentFieldMapper.joinField(parentType);
|
||||
IndexParentChildFieldData indexParentChildFieldData = parentChildIndexFieldData.loadGlobal(indexSearcher.getIndexReader());
|
||||
MultiDocValues.OrdinalMap ordinalMap = ParentChildIndexFieldData.getOrdinalMap(indexParentChildFieldData, parentType);
|
||||
return JoinUtil.createJoinQuery(joinField, innerQuery, toQuery, indexSearcher, scoreMode, ordinalMap, minChildren, maxChildren);
|
||||
|
@ -73,7 +73,16 @@ public class JvmInfo implements Streamable, ToXContent {
|
||||
// ignore
|
||||
}
|
||||
info.inputArguments = runtimeMXBean.getInputArguments().toArray(new String[runtimeMXBean.getInputArguments().size()]);
|
||||
info.bootClassPath = runtimeMXBean.getBootClassPath();
|
||||
try {
|
||||
info.bootClassPath = runtimeMXBean.getBootClassPath();
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// oracle java 9
|
||||
info.bootClassPath = System.getProperty("sun.boot.class.path");
|
||||
if (info.bootClassPath == null) {
|
||||
// something else
|
||||
info.bootClassPath = "<unknown>";
|
||||
}
|
||||
}
|
||||
info.classPath = runtimeMXBean.getClassPath();
|
||||
info.systemProperties = runtimeMXBean.getSystemProperties();
|
||||
|
||||
|
@ -227,6 +227,7 @@ public class OsStats implements Streamable, ToXContent {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: if values are -1, this should return -1 to show its unsupported?
|
||||
private static short calculatePercentage(long used, long max) {
|
||||
return max <= 0 ? 0 : (short) (Math.round((100d * used) / max));
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.PosixFileAttributeView;
|
||||
@ -315,10 +314,7 @@ public class PluginManager {
|
||||
private void jarHellCheck(Path candidate, boolean isolated) throws IOException {
|
||||
// create list of current jars in classpath
|
||||
final List<URL> jars = new ArrayList<>();
|
||||
ClassLoader loader = PluginManager.class.getClassLoader();
|
||||
if (loader instanceof URLClassLoader) {
|
||||
Collections.addAll(jars, ((URLClassLoader) loader).getURLs());
|
||||
}
|
||||
jars.addAll(Arrays.asList(JarHell.parseClassPath()));
|
||||
|
||||
// read existing bundles. this does some checks on the installation too.
|
||||
List<Bundle> bundles = PluginsService.getPluginBundles(environment.pluginsFile());
|
||||
|
@ -47,6 +47,7 @@ import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -331,12 +332,7 @@ public class PluginsService extends AbstractComponent {
|
||||
// pluginmanager does it, but we do it again, in case lusers mess with jar files manually
|
||||
try {
|
||||
final List<URL> jars = new ArrayList<>();
|
||||
ClassLoader parentLoader = getClass().getClassLoader();
|
||||
if (parentLoader instanceof URLClassLoader) {
|
||||
for (URL url : ((URLClassLoader) parentLoader).getURLs()) {
|
||||
jars.add(url);
|
||||
}
|
||||
}
|
||||
jars.addAll(Arrays.asList(JarHell.parseClassPath()));
|
||||
jars.addAll(bundle.urls);
|
||||
JarHell.checkJarHell(jars.toArray(new URL[0]));
|
||||
} catch (Exception e) {
|
||||
|
@ -79,15 +79,15 @@ public final class CustomQueryScorer extends QueryScorer {
|
||||
Map<String, WeightedSpanTerm> terms) throws IOException {
|
||||
if (query instanceof FunctionScoreQuery) {
|
||||
query = ((FunctionScoreQuery) query).getSubQuery();
|
||||
extract(query, terms);
|
||||
extract(query, query.getBoost(), terms);
|
||||
} else if (query instanceof FiltersFunctionScoreQuery) {
|
||||
query = ((FiltersFunctionScoreQuery) query).getSubQuery();
|
||||
extract(query, terms);
|
||||
extract(query, query.getBoost(), terms);
|
||||
} else if (query instanceof FilteredQuery) {
|
||||
query = ((FilteredQuery) query).getQuery();
|
||||
extract(query, terms);
|
||||
extract(query, 1F, terms);
|
||||
} else {
|
||||
extractWeightedTerms(terms, query);
|
||||
extractWeightedTerms(terms, query, query.getBoost());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,10 @@ grant codeBase "${es.security.jar.lucene.core}" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
|
||||
};
|
||||
|
||||
//// test framework permissions.
|
||||
//// These are mock objects and test management that we allow test framework libs
|
||||
//// to provide on our behalf. But tests themselves cannot do this stuff!
|
||||
|
||||
grant codeBase "${es.security.jar.elasticsearch.securemock}" {
|
||||
// needed to support creation of mocks
|
||||
permission java.lang.RuntimePermission "reflectionFactoryAccess";
|
||||
@ -80,8 +84,6 @@ grant {
|
||||
permission java.lang.RuntimePermission "getProtectionDomain";
|
||||
|
||||
// reflection hacks:
|
||||
// needed for mock filesystems in tests (to capture implCloseChannel)
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
// needed by groovy engine
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
|
||||
// needed by aws core sdk (TODO: look into this)
|
||||
|
@ -24,6 +24,7 @@ import org.apache.lucene.index.IndexFormatTooNewException;
|
||||
import org.apache.lucene.index.IndexFormatTooOldException;
|
||||
import org.apache.lucene.store.AlreadyClosedException;
|
||||
import org.apache.lucene.store.LockObtainFailedException;
|
||||
import org.apache.lucene.util.Constants;
|
||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
@ -324,7 +325,12 @@ public class ESExceptionTests extends ESTestCase {
|
||||
} else {
|
||||
assertEquals(e.getCause().getClass(), NotSerializableExceptionWrapper.class);
|
||||
}
|
||||
assertArrayEquals(e.getStackTrace(), ex.getStackTrace());
|
||||
// TODO: fix this test
|
||||
// on java 9, expected:<sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)>
|
||||
// but was:<sun.reflect.NativeMethodAccessorImpl.invoke0(java.base@9.0/Native Method)>
|
||||
if (!Constants.JRE_IS_MINIMUM_JAVA9) {
|
||||
assertArrayEquals(e.getStackTrace(), ex.getStackTrace());
|
||||
}
|
||||
assertTrue(e.getStackTrace().length > 1);
|
||||
ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), t);
|
||||
ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(getRandom()), ex);
|
||||
|
@ -21,6 +21,8 @@ package org.elasticsearch;
|
||||
import com.fasterxml.jackson.core.JsonLocation;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.lucene.util.Constants;
|
||||
import org.codehaus.groovy.runtime.typehandling.GroovyCastException;
|
||||
import org.elasticsearch.action.FailedNodeException;
|
||||
import org.elasticsearch.action.RoutingMissingException;
|
||||
@ -567,12 +569,15 @@ public class ExceptionSerializationTests extends ESTestCase {
|
||||
}
|
||||
Throwable deserialized = serialize(t);
|
||||
assertTrue(deserialized instanceof NotSerializableExceptionWrapper);
|
||||
assertArrayEquals(t.getStackTrace(), deserialized.getStackTrace());
|
||||
assertEquals(t.getSuppressed().length, deserialized.getSuppressed().length);
|
||||
if (t.getSuppressed().length > 0) {
|
||||
assertTrue(deserialized.getSuppressed()[0] instanceof NotSerializableExceptionWrapper);
|
||||
assertArrayEquals(t.getSuppressed()[0].getStackTrace(), deserialized.getSuppressed()[0].getStackTrace());
|
||||
assertTrue(deserialized.getSuppressed()[1] instanceof NullPointerException);
|
||||
// TODO: fix this test for more java 9 differences
|
||||
if (!Constants.JRE_IS_MINIMUM_JAVA9) {
|
||||
assertArrayEquals(t.getStackTrace(), deserialized.getStackTrace());
|
||||
assertEquals(t.getSuppressed().length, deserialized.getSuppressed().length);
|
||||
if (t.getSuppressed().length > 0) {
|
||||
assertTrue(deserialized.getSuppressed()[0] instanceof NotSerializableExceptionWrapper);
|
||||
assertArrayEquals(t.getSuppressed()[0].getStackTrace(), deserialized.getSuppressed()[0].getStackTrace());
|
||||
assertTrue(deserialized.getSuppressed()[1] instanceof NullPointerException);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class BootstrapForTesting {
|
||||
// initialize paths the same exact way as bootstrap.
|
||||
Permissions perms = new Permissions();
|
||||
// add permissions to everything in classpath
|
||||
for (URL url : ((URLClassLoader)BootstrapForTesting.class.getClassLoader()).getURLs()) {
|
||||
for (URL url : JarHell.parseClassPath()) {
|
||||
Path path = PathUtils.get(url.toURI());
|
||||
// resource itself
|
||||
perms.add(new FilePermission(path.toString(), "read,readlink"));
|
||||
@ -115,7 +115,7 @@ public class BootstrapForTesting {
|
||||
perms.add(new FilePermission(coverageDir.resolve("jacoco-it.exec").toString(), "read,write"));
|
||||
}
|
||||
Policy.setPolicy(new ESPolicy(perms));
|
||||
System.setSecurityManager(new XTestSecurityManager());
|
||||
System.setSecurityManager(new TestSecurityManager());
|
||||
Security.selfTest();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("unable to install test security manager", e);
|
||||
|
@ -1,113 +0,0 @@
|
||||
package org.elasticsearch.bootstrap;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// the above license header is a lie, here is the real one.
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A {@link SecurityManager} that prevents tests calling {@link System#exit(int)}.
|
||||
* Only the test runner itself is allowed to exit the JVM.
|
||||
* All other security checks are handled by the default security policy.
|
||||
* <p>
|
||||
* Use this with {@code -Djava.security.manager=org.apache.lucene.util.TestSecurityManager}.
|
||||
*/
|
||||
// TODO: remove me when https://issues.apache.org/jira/browse/LUCENE-6794 is committed
|
||||
public final class XTestSecurityManager extends SecurityManager {
|
||||
|
||||
static final String JUNIT4_TEST_RUNNER_PACKAGE = "com.carrotsearch.ant.tasks.junit4.";
|
||||
static final String ECLIPSE_TEST_RUNNER_PACKAGE = "org.eclipse.jdt.internal.junit.runner.";
|
||||
static final String IDEA_TEST_RUNNER_PACKAGE = "com.intellij.rt.execution.junit.";
|
||||
|
||||
/**
|
||||
* Creates a new TestSecurityManager. This ctor is called on JVM startup,
|
||||
* when {@code -Djava.security.manager=org.apache.lucene.util.TestSecurityManager}
|
||||
* is passed to JVM.
|
||||
*/
|
||||
public XTestSecurityManager() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>This method inspects the stack trace and checks who is calling
|
||||
* {@link System#exit(int)} and similar methods
|
||||
* @throws SecurityException if the caller of this method is not the test runner itself.
|
||||
*/
|
||||
@Override
|
||||
public void checkExit(final int status) {
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
final String systemClassName = System.class.getName(),
|
||||
runtimeClassName = Runtime.class.getName();
|
||||
String exitMethodHit = null;
|
||||
for (final StackTraceElement se : Thread.currentThread().getStackTrace()) {
|
||||
final String className = se.getClassName(), methodName = se.getMethodName();
|
||||
if (
|
||||
("exit".equals(methodName) || "halt".equals(methodName)) &&
|
||||
(systemClassName.equals(className) || runtimeClassName.equals(className))
|
||||
) {
|
||||
exitMethodHit = className + '#' + methodName + '(' + status + ')';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (exitMethodHit != null) {
|
||||
if (className.startsWith(JUNIT4_TEST_RUNNER_PACKAGE) ||
|
||||
className.startsWith(ECLIPSE_TEST_RUNNER_PACKAGE) ||
|
||||
className.startsWith(IDEA_TEST_RUNNER_PACKAGE)) {
|
||||
// this exit point is allowed, we return normally from closure:
|
||||
return /*void*/ null;
|
||||
} else {
|
||||
// anything else in stack trace is not allowed, break and throw SecurityException below:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (exitMethodHit == null) {
|
||||
// should never happen, only if JVM hides stack trace - replace by generic:
|
||||
exitMethodHit = "JVM exit method";
|
||||
}
|
||||
throw new SecurityException(exitMethodHit + " calls are not allowed because they terminate the test runner's JVM.");
|
||||
});
|
||||
|
||||
// we passed the stack check, delegate to super, so default policy can still deny permission:
|
||||
super.checkExit(status);
|
||||
}
|
||||
|
||||
}
|
@ -32,6 +32,7 @@ import org.apache.lucene.queries.TermsQuery;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.BoostQuery;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.DisjunctionMaxQuery;
|
||||
import org.apache.lucene.search.FuzzyQuery;
|
||||
@ -198,25 +199,30 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
public void testQueryStringBoostsBuilder() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
QueryStringQueryBuilder builder = queryStringQuery("field:boosted^2");
|
||||
Query expected = new BoostQuery(new TermQuery(new Term("field", "boosted")), 2);
|
||||
Query parsedQuery = queryParser.parse(builder).query();
|
||||
assertThat(parsedQuery, instanceOf(TermQuery.class));
|
||||
assertThat(((TermQuery) parsedQuery).getTerm(), equalTo(new Term("field", "boosted")));
|
||||
assertThat(parsedQuery.getBoost(), equalTo(2.0f));
|
||||
assertEquals(expected, parsedQuery);
|
||||
|
||||
builder.boost(2.0f);
|
||||
expected = new BoostQuery(new TermQuery(new Term("field", "boosted")), 4);
|
||||
parsedQuery = queryParser.parse(builder).query();
|
||||
assertThat(parsedQuery.getBoost(), equalTo(4.0f));
|
||||
assertEquals(expected, parsedQuery);
|
||||
|
||||
builder = queryStringQuery("((field:boosted^2) AND (field:foo^1.5))^3");
|
||||
expected = new BoostQuery(new BooleanQuery.Builder()
|
||||
.add(new BoostQuery(new TermQuery(new Term("field", "boosted")), 2), Occur.MUST)
|
||||
.add(new BoostQuery(new TermQuery(new Term("field", "foo")), 1.5f), Occur.MUST)
|
||||
.build(), 3);
|
||||
parsedQuery = queryParser.parse(builder).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
assertThat(assertBooleanSubQuery(parsedQuery, TermQuery.class, 0).getTerm(), equalTo(new Term("field", "boosted")));
|
||||
assertThat(assertBooleanSubQuery(parsedQuery, TermQuery.class, 0).getBoost(), equalTo(2.0f));
|
||||
assertThat(assertBooleanSubQuery(parsedQuery, TermQuery.class, 1).getTerm(), equalTo(new Term("field", "foo")));
|
||||
assertThat(assertBooleanSubQuery(parsedQuery, TermQuery.class, 1).getBoost(), equalTo(1.5f));
|
||||
assertThat(parsedQuery.getBoost(), equalTo(3.0f));
|
||||
assertEquals(expected, parsedQuery);
|
||||
|
||||
builder.boost(2.0f);
|
||||
expected = new BoostQuery(new BooleanQuery.Builder()
|
||||
.add(new BoostQuery(new TermQuery(new Term("field", "boosted")), 2), Occur.MUST)
|
||||
.add(new BoostQuery(new TermQuery(new Term("field", "foo")), 1.5f), Occur.MUST)
|
||||
.build(), 6);
|
||||
parsedQuery = queryParser.parse(builder).query();
|
||||
assertThat(parsedQuery.getBoost(), equalTo(6.0f));
|
||||
assertEquals(expected, parsedQuery);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1947,10 +1953,8 @@ public class SimpleIndexQueryParserTests extends ESSingleNodeTestCase {
|
||||
|
||||
BooleanQuery.Builder expected = new BooleanQuery.Builder();
|
||||
expected.add(new TermQuery(new Term("foobar", "banon")), Occur.SHOULD);
|
||||
TermQuery tq1 = new TermQuery(new Term("name.first", "banon"));
|
||||
tq1.setBoost(2);
|
||||
TermQuery tq2 = new TermQuery(new Term("name.last", "banon"));
|
||||
tq2.setBoost(3);
|
||||
Query tq1 = new BoostQuery(new TermQuery(new Term("name.first", "banon")), 2);
|
||||
Query tq2 = new BoostQuery(new TermQuery(new Term("name.last", "banon")), 3);
|
||||
expected.add(new DisjunctionMaxQuery(Arrays.<Query>asList(tq1, tq2), 0f), Occur.SHOULD);
|
||||
assertEquals(expected.build(), rewrittenQuery);
|
||||
}
|
||||
|
@ -54,11 +54,14 @@ public class OsProbeTests extends ESTestCase {
|
||||
}
|
||||
|
||||
assertNotNull(stats.getMem());
|
||||
assertThat(stats.getMem().getTotal().bytes(), greaterThan(0L));
|
||||
assertThat(stats.getMem().getFree().bytes(), greaterThan(0L));
|
||||
assertThat(stats.getMem().getFreePercent(), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100)));
|
||||
assertThat(stats.getMem().getUsed().bytes(), greaterThan(0L));
|
||||
assertThat(stats.getMem().getUsedPercent(), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100)));
|
||||
// TODO: once java 9 is sorted out make these hard checks (currently 9-ea and 9-ea-jigsaw will differ)
|
||||
if (!Constants.JRE_IS_MINIMUM_JAVA9) {
|
||||
assertThat(stats.getMem().getTotal().bytes(), greaterThan(0L));
|
||||
assertThat(stats.getMem().getFree().bytes(), greaterThan(0L));
|
||||
assertThat(stats.getMem().getFreePercent(), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100)));
|
||||
assertThat(stats.getMem().getUsed().bytes(), greaterThan(0L));
|
||||
assertThat(stats.getMem().getUsedPercent(), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100)));
|
||||
}
|
||||
|
||||
assertNotNull(stats.getSwap());
|
||||
assertNotNull(stats.getSwap().getTotal());
|
||||
@ -70,9 +73,12 @@ public class OsProbeTests extends ESTestCase {
|
||||
assertThat(stats.getSwap().getUsed().bytes(), greaterThanOrEqualTo(0L));
|
||||
} else {
|
||||
// On platforms with no swap
|
||||
assertThat(stats.getSwap().getTotal().bytes(), equalTo(0L));
|
||||
assertThat(stats.getSwap().getFree().bytes(), equalTo(0L));
|
||||
assertThat(stats.getSwap().getUsed().bytes(), equalTo(0L));
|
||||
// TODO: one java 9 is sorted out make these hard checks (currently 9-ea and 9-ea-jigsaw will differ)
|
||||
if (!Constants.JRE_IS_MINIMUM_JAVA9) {
|
||||
assertThat(stats.getSwap().getTotal().bytes(), equalTo(0L));
|
||||
assertThat(stats.getSwap().getFree().bytes(), equalTo(0L));
|
||||
assertThat(stats.getSwap().getUsed().bytes(), equalTo(0L));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +51,11 @@ public class ProcessProbeTests extends ESTestCase {
|
||||
assertThat(stats.getOpenFileDescriptors(), equalTo(-1L));
|
||||
assertThat(stats.getMaxFileDescriptors(), equalTo(-1L));
|
||||
} else {
|
||||
assertThat(stats.getOpenFileDescriptors(), greaterThan(0L));
|
||||
assertThat(stats.getMaxFileDescriptors(), greaterThan(0L));
|
||||
// TODO: once java 9 is sorted out make these hard checks (currently 9-ea and 9-ea-jigsaw will differ)
|
||||
if (!Constants.JRE_IS_MINIMUM_JAVA9) {
|
||||
assertThat(stats.getOpenFileDescriptors(), greaterThan(0L));
|
||||
assertThat(stats.getMaxFileDescriptors(), greaterThan(0L));
|
||||
}
|
||||
}
|
||||
|
||||
ProcessStats.Cpu cpu = stats.getCpu();
|
||||
@ -62,11 +65,14 @@ public class ProcessProbeTests extends ESTestCase {
|
||||
assertThat(cpu.getPercent(), anyOf(lessThan((short) 0), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100))));
|
||||
|
||||
// CPU time can return -1 if the the platform does not support this operation, let's see which platforms fail
|
||||
assertThat(cpu.total, greaterThan(0L));
|
||||
if (!Constants.JRE_IS_MINIMUM_JAVA9) {
|
||||
// TODO: once java 9 is sorted out make these hard checks (currently 9-ea and 9-ea-jigsaw will differ)
|
||||
assertThat(cpu.total, greaterThan(0L));
|
||||
|
||||
ProcessStats.Mem mem = stats.getMem();
|
||||
assertNotNull(mem);
|
||||
// Commited total virtual memory can return -1 if not supported, let's see which platforms fail
|
||||
assertThat(mem.totalVirtual, greaterThan(0L));
|
||||
ProcessStats.Mem mem = stats.getMem();
|
||||
assertNotNull(mem);
|
||||
// Commited total virtual memory can return -1 if not supported, let's see which platforms fail
|
||||
assertThat(mem.totalVirtual, greaterThan(0L));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ public class DirectBufferNetworkIT extends ESIntegTestCase {
|
||||
*/
|
||||
@Test
|
||||
public void verifySaneDirectBufferAllocations() throws Exception {
|
||||
assumeTrue("test cannot run with security manager enabled", System.getSecurityManager() == null);
|
||||
createIndex("test");
|
||||
|
||||
int estimatedBytesSize = scaledRandomIntBetween(ByteSizeValue.parseBytesSizeValue("1.1mb", "estimatedBytesSize").bytesAsInt(),
|
||||
|
@ -53,6 +53,7 @@ import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
|
||||
public class DecayFunctionScoreIT extends ESIntegTestCase {
|
||||
|
||||
@Test
|
||||
@ -348,7 +349,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
|
||||
SearchHits sh = sr.getHits();
|
||||
assertThat(sh.getTotalHits(), equalTo((long) (1)));
|
||||
assertThat(sh.getAt(0).getId(), equalTo("1"));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(0.30685282, 1.e-5));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(0.153426408, 1.e-5));
|
||||
|
||||
response = client().search(
|
||||
searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source(
|
||||
@ -359,7 +360,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
|
||||
sh = sr.getHits();
|
||||
assertThat(sh.getTotalHits(), equalTo((long) (1)));
|
||||
assertThat(sh.getAt(0).getId(), equalTo("1"));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(1.0, 1.e-5));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(0.5, 1.e-5));
|
||||
|
||||
response = client().search(
|
||||
searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source(
|
||||
@ -370,7 +371,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
|
||||
sh = sr.getHits();
|
||||
assertThat(sh.getTotalHits(), equalTo((long) (1)));
|
||||
assertThat(sh.getAt(0).getId(), equalTo("1"));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(2.0 * (0.30685282 + 0.5), 1.e-5));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(0.30685282 + 0.5, 1.e-5));
|
||||
logger.info("--> Hit[0] {} Explanation:\n {}", sr.getHits().getAt(0).id(), sr.getHits().getAt(0).explanation());
|
||||
|
||||
response = client().search(
|
||||
@ -382,7 +383,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
|
||||
sh = sr.getHits();
|
||||
assertThat(sh.getTotalHits(), equalTo((long) (1)));
|
||||
assertThat(sh.getAt(0).getId(), equalTo("1"));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo((0.30685282 + 0.5), 1.e-5));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo((0.30685282 + 0.5) / 2, 1.e-5));
|
||||
|
||||
response = client().search(
|
||||
searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source(
|
||||
@ -393,7 +394,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
|
||||
sh = sr.getHits();
|
||||
assertThat(sh.getTotalHits(), equalTo((long) (1)));
|
||||
assertThat(sh.getAt(0).getId(), equalTo("1"));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(2.0 * (0.30685282), 1.e-5));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(0.30685282, 1.e-5));
|
||||
|
||||
response = client().search(
|
||||
searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source(
|
||||
@ -404,7 +405,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
|
||||
sh = sr.getHits();
|
||||
assertThat(sh.getTotalHits(), equalTo((long) (1)));
|
||||
assertThat(sh.getAt(0).getId(), equalTo("1"));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(1.0, 1.e-5));
|
||||
assertThat((double) sh.getAt(0).score(), closeTo(0.5, 1.e-5));
|
||||
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class FunctionScoreIT extends ESIntegTestCase {
|
||||
|
||||
assertThat(
|
||||
responseWithWeights.getHits().getAt(0).getExplanation().toString(),
|
||||
equalTo("6.0 = function score, product of:\n 1.0 = ConstantScore(text_field:value), product of:\n 1.0 = boost\n 1.0 = queryNorm\n 6.0 = min of:\n 6.0 = function score, score mode [multiply]\n 1.0 = function score, product of:\n 1.0 = match filter: *:*\n 1.0 = Function for field geo_point_field:\n 1.0 = exp(-0.5*pow(MIN of: [Math.max(arcDistance([10.0, 20.0](=doc value),[10.0, 20.0](=origin)) - 0.0(=offset), 0)],2.0)/7.213475204444817E11)\n 2.0 = function score, product of:\n 1.0 = match filter: *:*\n 2.0 = product of:\n 1.0 = field value function: ln(doc['double_field'].value * factor=1.0)\n 2.0 = weight\n 3.0 = function score, product of:\n 1.0 = match filter: *:*\n 3.0 = product of:\n 1.0 = script score function, computed with script:\"[script: _index['text_field']['value'].tf(), type: inline, lang: null, params: null]\n 1.0 = _score: \n 1.0 = ConstantScore(text_field:value), product of:\n 1.0 = boost\n 1.0 = queryNorm\n 3.0 = weight\n 3.4028235E38 = maxBoost\n 1.0 = queryBoost\n"));
|
||||
equalTo("6.0 = function score, product of:\n 1.0 = ConstantScore(text_field:value), product of:\n 1.0 = boost\n 1.0 = queryNorm\n 6.0 = min of:\n 6.0 = function score, score mode [multiply]\n 1.0 = function score, product of:\n 1.0 = match filter: *:*\n 1.0 = Function for field geo_point_field:\n 1.0 = exp(-0.5*pow(MIN of: [Math.max(arcDistance([10.0, 20.0](=doc value),[10.0, 20.0](=origin)) - 0.0(=offset), 0)],2.0)/7.213475204444817E11)\n 2.0 = function score, product of:\n 1.0 = match filter: *:*\n 2.0 = product of:\n 1.0 = field value function: ln(doc['double_field'].value * factor=1.0)\n 2.0 = weight\n 3.0 = function score, product of:\n 1.0 = match filter: *:*\n 3.0 = product of:\n 1.0 = script score function, computed with script:\"[script: _index['text_field']['value'].tf(), type: inline, lang: null, params: null]\n 1.0 = _score: \n 1.0 = ConstantScore(text_field:value), product of:\n 1.0 = boost\n 1.0 = queryNorm\n 3.0 = weight\n 3.4028235E38 = maxBoost\n"));
|
||||
responseWithWeights = client().search(
|
||||
searchRequest().source(
|
||||
searchSource().query(
|
||||
@ -186,7 +186,7 @@ public class FunctionScoreIT extends ESIntegTestCase {
|
||||
.explain(true))).actionGet();
|
||||
assertThat(
|
||||
responseWithWeights.getHits().getAt(0).getExplanation().toString(),
|
||||
equalTo("4.0 = function score, product of:\n 1.0 = ConstantScore(text_field:value), product of:\n 1.0 = boost\n 1.0 = queryNorm\n 4.0 = min of:\n 4.0 = product of:\n 1.0 = constant score 1.0 - no function provided\n 4.0 = weight\n 3.4028235E38 = maxBoost\n 1.0 = queryBoost\n"));
|
||||
equalTo("4.0 = function score, product of:\n 1.0 = ConstantScore(text_field:value), product of:\n 1.0 = boost\n 1.0 = queryNorm\n 4.0 = min of:\n 4.0 = product of:\n 1.0 = constant score 1.0 - no function provided\n 4.0 = weight\n 3.4028235E38 = maxBoost\n"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -442,4 +442,4 @@ public class TribeIT extends ESIntegTestCase {
|
||||
}
|
||||
return unicastHosts.toArray(new String[unicastHosts.size()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
dev-tools/update_lucene.sh
Normal file
14
dev-tools/update_lucene.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
mvn install -DskipTests
|
||||
perl dev-tools/src/main/resources/license-check/check_license_and_sha.pl \
|
||||
--update distribution/licenses/ distribution/zip/target/releases/elasticsearch-3.0.0-SNAPSHOT.zip elasticsearch-3.0.0-SNAPSHOT
|
||||
perl dev-tools/src/main/resources/license-check/check_license_and_sha.pl \
|
||||
--update plugins/analysis-icu/licenses/ plugins/analysis-icu/target/releases/analysis-icu-3.0.0-SNAPSHOT.zip analysis-icu-3.0.0-SNAPSHOT
|
||||
perl dev-tools/src/main/resources/license-check/check_license_and_sha.pl \
|
||||
--update plugins/analysis-kuromoji/licenses/ plugins/analysis-kuromoji/target/releases/analysis-kuromoji-3.0.0-SNAPSHOT.zip analysis-kuromoji-3.0.0-SNAPSHOT
|
||||
perl dev-tools/src/main/resources/license-check/check_license_and_sha.pl \
|
||||
--update plugins/analysis-phonetic/licenses/ plugins/analysis-phonetic/target/releases/analysis-phonetic-3.0.0-SNAPSHOT.zip analysis-phonetic-3.0.0-SNAPSHOT
|
||||
perl dev-tools/src/main/resources/license-check/check_license_and_sha.pl \
|
||||
--update plugins/analysis-smartcn/licenses/ plugins/analysis-smartcn/target/releases/analysis-smartcn-3.0.0-SNAPSHOT.zip analysis-smartcn-3.0.0-SNAPSHOT
|
||||
perl dev-tools/src/main/resources/license-check/check_license_and_sha.pl \
|
||||
--update plugins/analysis-stempel/licenses/ plugins/analysis-stempel/target/releases/analysis-stempel-3.0.0-SNAPSHOT.zip analysis-stempel-3.0.0-SNAPSHOT
|
@ -1 +0,0 @@
|
||||
35fca29c4597a15ce4d4eb7dc73a517038684a27
|
@ -0,0 +1 @@
|
||||
8243b938b75818e86aa8d270d8d99529e1847578
|
@ -1 +0,0 @@
|
||||
e4769b5c05fad8339f4eaf9cfa9e850cbeaa10ec
|
@ -0,0 +1 @@
|
||||
ba85c6e5e77e1f76c52c31d34a59558afa135d47
|
@ -1 +0,0 @@
|
||||
3bbab9d7a395bd0b6cc8b5bee26287105c8659e8
|
@ -0,0 +1 @@
|
||||
f8a38658b6393015c9b33c16b1b4122167b526b2
|
@ -1 +0,0 @@
|
||||
d60476428e7d3d8a68fe491d42dbda0d4024f589
|
@ -0,0 +1 @@
|
||||
fa5d27ecadbe346caaf5a571ba71944b51761acf
|
@ -1 +0,0 @@
|
||||
8618da3f400f0a4b140f196bbbecb0686fe754db
|
@ -0,0 +1 @@
|
||||
2c1464fcf6ede7819f8ba434b9bc7c79f5968407
|
@ -1 +0,0 @@
|
||||
c7db4fe5587d08ab23b253c622566462aab6796a
|
@ -0,0 +1 @@
|
||||
a40f9a3ef224bc042ef2ad1b713e318911b6057a
|
@ -1 +0,0 @@
|
||||
f9c8d435d3e1d553b0dca05c99b1fa377568eed0
|
@ -0,0 +1 @@
|
||||
0a7642c9b98cb3d9013fb33be5c0751baf9f0b31
|
@ -1 +0,0 @@
|
||||
571dd2e4363f0a0410de04b3f3f4bbf66e782c31
|
@ -0,0 +1 @@
|
||||
a0d6461ab9cda93ea530560b0c074a28fe0dd717
|
@ -1 +0,0 @@
|
||||
423264f839aace3b9159a0dd54f56c250458fd46
|
@ -0,0 +1 @@
|
||||
85c5c7b78715c50157700c90ffd101537446533d
|
@ -1 +0,0 @@
|
||||
872530eeac156faa0989eb87145bbef74a72e66f
|
@ -0,0 +1 @@
|
||||
70ca782d6ed458b5f777141353e09600083ed4fe
|
@ -1 +0,0 @@
|
||||
6f6b6a024ca96017252efea6d2fc7dc97c69febd
|
@ -0,0 +1 @@
|
||||
b4832cdfe7a6cc7c586a3e28d7cd530acb182232
|
@ -1 +0,0 @@
|
||||
a6f5a5c84b165ebde104cdcde46fa9c5948650f0
|
@ -0,0 +1 @@
|
||||
bde73ae2b2324e1576c5789a7e6dd88b6543b939
|
@ -1 +0,0 @@
|
||||
a305601f93b6cb02444816c96276a74f91ac7d40
|
@ -0,0 +1 @@
|
||||
8d261ff1c2333ce1e040c3aefca9784d1ae71acc
|
@ -1 +0,0 @@
|
||||
ef1fcaa5b6663dd9382719a1ad40d86fc962c690
|
@ -0,0 +1 @@
|
||||
ee041e52dfcdb33a1aa6fab112042b5f33fc0c0c
|
@ -1 +0,0 @@
|
||||
3698e0623f45e181d2ceead46e48a6dd8c2867dd
|
@ -0,0 +1 @@
|
||||
a8ceb11b26e53612eee9a265ff454351f6dc99f2
|
@ -1 +0,0 @@
|
||||
b7f57ef60f302b30e88196d4f0d11f789c5cfabd
|
@ -0,0 +1 @@
|
||||
1f92d0376ca9219b0bf96fe5bd9a913089608d6a
|
@ -1 +0,0 @@
|
||||
5d1023fc3f28a42357d44d3a330ac0df1df4bf42
|
@ -0,0 +1 @@
|
||||
60ee5bc1ac8ec102434e7064141a1f40281918b5
|
@ -1 +0,0 @@
|
||||
654c3e345ffdd74605582d1320c51c1c550a5cca
|
@ -0,0 +1 @@
|
||||
977aa506485d358b40602347c11238b0f912fe2c
|
@ -1 +0,0 @@
|
||||
80c09e367abf2ad936c86cf74a16ae2b4e805b81
|
@ -0,0 +1 @@
|
||||
61911b8400160bd206ea6ea46ba08fd9ba09e72b
|
@ -1 +0,0 @@
|
||||
7c6ae4fc7e8e1d39c155068fea67b7fabb12c444
|
@ -0,0 +1 @@
|
||||
5a9bdf48b63562bf1ac8a73c1c6bdb4cc450439e
|
@ -1,6 +1,9 @@
|
||||
# Integration tests for Repository S3 component
|
||||
#
|
||||
"S3 repository can be registereed":
|
||||
- skip:
|
||||
version: "all"
|
||||
reason: does not work on java9, see https://github.com/aws/aws-sdk-java/pull/432
|
||||
- do:
|
||||
snapshot.create_repository:
|
||||
repository: test_repo_s3_1
|
||||
|
4
pom.xml
4
pom.xml
@ -45,7 +45,7 @@
|
||||
|
||||
<!-- libraries -->
|
||||
<lucene.version>5.4.0</lucene.version>
|
||||
<lucene.snapshot.revision>1701068</lucene.snapshot.revision>
|
||||
<lucene.snapshot.revision>1702265</lucene.snapshot.revision>
|
||||
<lucene.maven.version>5.4.0-snapshot-${lucene.snapshot.revision}</lucene.maven.version>
|
||||
<testframework.version>2.1.16</testframework.version>
|
||||
<jackson.version>2.5.3</jackson.version>
|
||||
@ -582,7 +582,7 @@
|
||||
<arg>-XDignore.symbol.file</arg>
|
||||
<arg>-Xlint:all</arg>
|
||||
<arg>${xlint.options}</arg>
|
||||
<arg>-Werror</arg>
|
||||
<!-- DISABLED: incompatible with java 9 <arg>-Werror</arg> -->
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -69,7 +69,7 @@ public abstract class ESSmokeClientTestCase extends LuceneTestCase {
|
||||
*/
|
||||
public static final String TESTS_CLUSTER_DEFAULT = "localhost:9300";
|
||||
|
||||
protected static ESLogger logger = ESLoggerFactory.getLogger(ESSmokeClientTestCase.class.getName());
|
||||
protected static final ESLogger logger = ESLoggerFactory.getLogger(ESSmokeClientTestCase.class.getName());
|
||||
|
||||
private static final AtomicInteger counter = new AtomicInteger();
|
||||
private static Client client;
|
||||
|
Loading…
x
Reference in New Issue
Block a user