expose simplified field methods for custom scripts
also, add respective iter methods to the script values to be used in custom scripts
This commit is contained in:
parent
3ac3c7d12c
commit
594e03b695
|
@ -98,6 +98,18 @@ public abstract class ScriptDocValues {
|
||||||
return !values.hasValue(docId);
|
return !values.hasValue(docId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BytesValues getInternalValues() {
|
||||||
|
return this.values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iter getBytesIter() {
|
||||||
|
return values.getIter(docId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BytesRef getBytesValue() {
|
||||||
|
return values.getValue(docId);
|
||||||
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
final BytesRef value = values.getValue(docId);
|
final BytesRef value = values.getValue(docId);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
@ -137,11 +149,19 @@ public abstract class ScriptDocValues {
|
||||||
this.list = new SlicedLongList(values.isMultiValued() ? 10 : 1);
|
this.list = new SlicedLongList(values.isMultiValued() ? 10 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LongValues getInternalValues() {
|
||||||
|
return this.values;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return !values.hasValue(docId);
|
return !values.hasValue(docId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LongValues.Iter getIter() {
|
||||||
|
return values.getIter(docId);
|
||||||
|
}
|
||||||
|
|
||||||
public long getValue() {
|
public long getValue() {
|
||||||
return values.getValue(docId);
|
return values.getValue(docId);
|
||||||
}
|
}
|
||||||
|
@ -178,11 +198,19 @@ public abstract class ScriptDocValues {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DoubleValues getInternalValues() {
|
||||||
|
return this.values;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return !values.hasValue(docId);
|
return !values.hasValue(docId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DoubleValues.Iter getIter() {
|
||||||
|
return values.getIter(docId);
|
||||||
|
}
|
||||||
|
|
||||||
public double getValue() {
|
public double getValue() {
|
||||||
return values.getValue(docId);
|
return values.getValue(docId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.script;
|
||||||
|
|
||||||
import org.apache.lucene.index.AtomicReaderContext;
|
import org.apache.lucene.index.AtomicReaderContext;
|
||||||
import org.apache.lucene.search.Scorer;
|
import org.apache.lucene.search.Scorer;
|
||||||
|
import org.elasticsearch.index.fielddata.ScriptDocValues;
|
||||||
import org.elasticsearch.search.lookup.DocLookup;
|
import org.elasticsearch.search.lookup.DocLookup;
|
||||||
import org.elasticsearch.search.lookup.FieldsLookup;
|
import org.elasticsearch.search.lookup.FieldsLookup;
|
||||||
import org.elasticsearch.search.lookup.SearchLookup;
|
import org.elasticsearch.search.lookup.SearchLookup;
|
||||||
|
@ -59,6 +60,27 @@ public abstract class AbstractSearchScript extends AbstractExecutableScript impl
|
||||||
return lookup.doc();
|
return lookup.doc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns field data strings access for the provided field.
|
||||||
|
*/
|
||||||
|
protected ScriptDocValues.Strings docFieldStrings(String field) {
|
||||||
|
return (ScriptDocValues.Strings) doc().get(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns field data double (floating point) access for the provided field.
|
||||||
|
*/
|
||||||
|
protected ScriptDocValues.Doubles docFieldDoubles(String field) {
|
||||||
|
return (ScriptDocValues.Doubles) doc().get(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns field data long (integers) access for the provided field.
|
||||||
|
*/
|
||||||
|
protected ScriptDocValues.Longs docFieldLongs(String field) {
|
||||||
|
return (ScriptDocValues.Longs) doc().get(field);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to access the actual source (loaded and parsed).
|
* Allows to access the actual source (loaded and parsed).
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue