summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java
diff options
context:
space:
mode:
authorAdrien Grand <jpountz@gmail.com>2017-04-18 15:17:21 +0200
committerGitHub <noreply@github.com>2017-04-18 15:17:21 +0200
commit4632661bc71bb22fc577df476e70e9dfabaaae66 (patch)
tree6e10e1ffaa792c5fa46251d861736e59c9ed3404 /core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java
parentf217eb8ad8d3ecc82e2f926222b1f036b0d555b7 (diff)
Upgrade to a Lucene 7 snapshot (#24089)
We want to upgrade to Lucene 7 ahead of time in order to be able to check whether it causes any trouble to Elasticsearch before Lucene 7.0 gets released. From a user perspective, the main benefit of this upgrade is the enhanced support for sparse fields, whose resource consumption is now function of the number of docs that have a value rather than the total number of docs in the index. Some notes about the change: - it includes the deprecation of the `disable_coord` parameter of the `bool` and `common_terms` queries: Lucene has removed support for coord factors - it includes the deprecation of the `index.similarity.base` expert setting, since it was only useful to configure coords and query norms, which have both been removed - two tests have been marked with `@AwaitsFix` because of #23966, which we intend to address after the merge
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java')
-rw-r--r--core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java b/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java
index ec4e19d1ee..2901e05f05 100644
--- a/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java
+++ b/core/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java
@@ -32,6 +32,7 @@ import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.index.fielddata.AbstractBinaryDocValues;
import org.elasticsearch.index.fielddata.FieldData;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
@@ -261,16 +262,20 @@ public class ScriptSortBuilder extends SortBuilder<ScriptSortBuilder> {
@Override
protected SortedBinaryDocValues getValues(LeafReaderContext context) throws IOException {
leafScript = searchScript.getLeafSearchScript(context);
- final BinaryDocValues values = new BinaryDocValues() {
+ final BinaryDocValues values = new AbstractBinaryDocValues() {
final BytesRefBuilder spare = new BytesRefBuilder();
@Override
- public BytesRef get(int docID) {
- leafScript.setDocument(docID);
+ public boolean advanceExact(int doc) throws IOException {
+ leafScript.setDocument(doc);
+ return true;
+ }
+ @Override
+ public BytesRef binaryValue() {
spare.copyChars(leafScript.run().toString());
return spare.get();
}
};
- return FieldData.singleton(values, null);
+ return FieldData.singleton(values);
}
@Override
protected void setScorer(Scorer scorer) {
@@ -286,12 +291,16 @@ public class ScriptSortBuilder extends SortBuilder<ScriptSortBuilder> {
leafScript = searchScript.getLeafSearchScript(context);
final NumericDoubleValues values = new NumericDoubleValues() {
@Override
- public double get(int docID) {
- leafScript.setDocument(docID);
+ public boolean advanceExact(int doc) throws IOException {
+ leafScript.setDocument(doc);
+ return false;
+ }
+ @Override
+ public double doubleValue() {
return leafScript.runAsDouble();
}
};
- return FieldData.singleton(values, null);
+ return FieldData.singleton(values);
}
@Override
protected void setScorer(Scorer scorer) {