refactor a bit search script execution

This commit is contained in:
kimchy 2011-01-31 01:29:30 +02:00
parent 919143f6b6
commit bdb87c7a62
24 changed files with 109 additions and 117 deletions

View File

@ -22,7 +22,7 @@ package org.elasticsearch.index.field.function.sort;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.FieldComparatorSource;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import java.io.IOException;
@ -32,15 +32,15 @@ import java.io.IOException;
// LUCENE MONITOR: Monitor against FieldComparator.Double
public class DoubleFieldsFunctionDataComparator extends FieldComparator {
public static FieldComparatorSource comparatorSource(SearchScript script) {
public static FieldComparatorSource comparatorSource(ExecutableSearchScript script) {
return new InnerSource(script);
}
private static class InnerSource extends FieldComparatorSource {
private final SearchScript script;
private final ExecutableSearchScript script;
private InnerSource(SearchScript script) {
private InnerSource(ExecutableSearchScript script) {
this.script = script;
}
@ -49,12 +49,12 @@ public class DoubleFieldsFunctionDataComparator extends FieldComparator {
}
}
private final SearchScript script;
private final ExecutableSearchScript script;
private final double[] values;
private double bottom;
public DoubleFieldsFunctionDataComparator(int numHits, SearchScript script) {
public DoubleFieldsFunctionDataComparator(int numHits, ExecutableSearchScript script) {
this.script = script;
values = new double[numHits];
}

View File

@ -22,7 +22,7 @@ package org.elasticsearch.index.field.function.sort;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.FieldComparatorSource;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import java.io.IOException;
@ -31,15 +31,15 @@ import java.io.IOException;
*/
public class StringFieldsFunctionDataComparator extends FieldComparator {
public static FieldComparatorSource comparatorSource(SearchScript script) {
public static FieldComparatorSource comparatorSource(ExecutableSearchScript script) {
return new InnerSource(script);
}
private static class InnerSource extends FieldComparatorSource {
private final SearchScript script;
private final ExecutableSearchScript script;
private InnerSource(SearchScript script) {
private InnerSource(ExecutableSearchScript script) {
this.script = script;
}
@ -48,13 +48,13 @@ public class StringFieldsFunctionDataComparator extends FieldComparator {
}
}
private final SearchScript script;
private final ExecutableSearchScript script;
private String[] values;
private String bottom;
public StringFieldsFunctionDataComparator(int numHits, SearchScript script) {
public StringFieldsFunctionDataComparator(int numHits, ExecutableSearchScript script) {
this.script = script;
values = new String[numHits];
}

View File

@ -34,7 +34,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.query.QueryParsingException;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException;
@ -96,7 +96,7 @@ public class CustomScoreQueryParser extends AbstractIndexComponent implements XC
if (context == null) {
throw new ElasticSearchIllegalStateException("No search context on going...");
}
SearchScript searchScript = new SearchScript(context.lookup(), scriptLang, script, vars, parseContext.scriptService());
ExecutableSearchScript searchScript = new ExecutableSearchScript(context.lookup(), scriptLang, script, vars, parseContext.scriptService());
FunctionScoreQuery functionScoreQuery = new FunctionScoreQuery(query, new ScriptScoreFunction(searchScript));
functionScoreQuery.setBoost(boost);
return functionScoreQuery;
@ -104,11 +104,11 @@ public class CustomScoreQueryParser extends AbstractIndexComponent implements XC
public static class ScriptScoreFunction implements ScoreFunction {
private final SearchScript script;
private final ExecutableSearchScript script;
private Map<String, Object> vars = Maps.newHashMapWithExpectedSize(2);
private ScriptScoreFunction(SearchScript script) {
private ScriptScoreFunction(ExecutableSearchScript script) {
this.script = script;
}

View File

@ -32,8 +32,8 @@ import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.query.QueryParsingException;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException;
@ -110,7 +110,7 @@ public class ScriptFilterParser extends AbstractIndexComponent implements XConte
private final Map<String, Object> params;
private final SearchScript searchScript;
private final ExecutableSearchScript searchScript;
private ScriptFilter(String scriptLang, String script, Map<String, Object> params, ScriptService scriptService) {
this.script = script;
@ -121,7 +121,7 @@ public class ScriptFilterParser extends AbstractIndexComponent implements XConte
throw new ElasticSearchIllegalStateException("No search context on going...");
}
this.searchScript = new SearchScript(context.lookup(), scriptLang, script, params, scriptService);
this.searchScript = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, scriptService);
}
@Override public String toString() {
@ -157,9 +157,9 @@ public class ScriptFilterParser extends AbstractIndexComponent implements XConte
static class ScriptDocSet extends GetDocSet {
private final SearchScript searchScript;
private final ExecutableSearchScript searchScript;
public ScriptDocSet(IndexReader reader, SearchScript searchScript) {
public ScriptDocSet(IndexReader reader, ExecutableSearchScript searchScript) {
super(reader.maxDoc());
this.searchScript = searchScript;
}

View File

@ -17,14 +17,12 @@
* under the License.
*/
package org.elasticsearch.script.search;
package org.elasticsearch.script;
import org.apache.lucene.index.IndexReader;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.lookup.SearchLookup;
import java.util.Map;
@ -32,27 +30,21 @@ import java.util.Map;
/**
* @author kimchy (shay.banon)
*/
public class SearchScript {
public class ExecutableSearchScript {
private final SearchLookup searchLookup;
private final ExecutableScript script;
public SearchScript(SearchLookup searchLookup, ExecutableScript script) {
this.searchLookup = searchLookup;
this.script = script;
public ExecutableSearchScript(String lang, String script, @Nullable Map<String, Object> params, ScriptService scriptService, MapperService mapperService, FieldDataCache fieldDataCache) {
this(new SearchLookup(mapperService, fieldDataCache), lang, script, params, scriptService);
}
public SearchScript(SearchLookup searchLookup, String lang, String script, @Nullable Map<String, Object> params, ScriptService scriptService) {
public ExecutableSearchScript(SearchLookup searchLookup, String lang, String script, @Nullable Map<String, Object> params, ScriptService scriptService) {
this.searchLookup = searchLookup;
this.script = scriptService.executable(lang, script, searchLookup.processAsMap(params));
}
public SearchScript(String lang, String script, @Nullable Map<String, Object> params, ScriptService scriptService, MapperService mapperService, FieldDataCache fieldDataCache) {
this.searchLookup = new SearchLookup(mapperService, fieldDataCache);
this.script = scriptService.executable(lang, script, searchLookup.processAsMap(params));
}
public void setNextReader(IndexReader reader) {
searchLookup.setNextReader(reader);
}

View File

@ -28,7 +28,7 @@ import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.longs.LongFieldData;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -57,7 +57,7 @@ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollect
private LongFieldData fieldData;
private final SearchScript valueScript;
private final ExecutableSearchScript valueScript;
private final DateHistogramProc histoProc;
@ -77,7 +77,7 @@ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollect
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
this.valueScript = new SearchScript(context.lookup(), scriptLang, valueScript, params, context.scriptService());
this.valueScript = new ExecutableSearchScript(context.lookup(), scriptLang, valueScript, params, context.scriptService());
FieldMapper mapper = smartMappers.mapper();
@ -106,13 +106,13 @@ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollect
public static class DateHistogramProc implements LongFieldData.DateValueInDocProc {
protected final SearchScript valueScript;
protected final ExecutableSearchScript valueScript;
protected final TLongLongHashMap counts = new TLongLongHashMap();
protected final TLongDoubleHashMap totals = new TLongDoubleHashMap();
public DateHistogramProc(SearchScript valueScript) {
public DateHistogramProc(ExecutableSearchScript valueScript) {
this.valueScript = valueScript;
}
@ -137,7 +137,7 @@ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollect
private final long interval;
public IntervalDateHistogramProc(long interval, SearchScript valueScript) {
public IntervalDateHistogramProc(long interval, ExecutableSearchScript valueScript) {
super(valueScript);
this.interval = interval;
}

View File

@ -23,7 +23,7 @@ import org.apache.lucene.index.IndexReader;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.index.mapper.xcontent.geo.GeoPoint;
import org.elasticsearch.index.search.geo.GeoDistance;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException;
@ -34,14 +34,14 @@ import java.util.Map;
*/
public class ScriptGeoDistanceFacetCollector extends GeoDistanceFacetCollector {
private final SearchScript script;
private final ExecutableSearchScript script;
public ScriptGeoDistanceFacetCollector(String facetName, String fieldName, double lat, double lon, DistanceUnit unit, GeoDistance geoDistance,
GeoDistanceFacet.Entry[] entries, SearchContext context,
String scriptLang, String script, Map<String, Object> params) {
super(facetName, fieldName, lat, lon, unit, geoDistance, entries, context);
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
}
@Override protected void doSetNextReader(IndexReader reader, int docBase) throws IOException {

View File

@ -27,7 +27,7 @@ import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.NumericFieldData;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -54,7 +54,7 @@ public class KeyValueScriptHistogramFacetCollector extends AbstractFacetCollecto
private NumericFieldData fieldData;
private final SearchScript valueScript;
private final ExecutableSearchScript valueScript;
private final HistogramProc histoProc;
@ -73,7 +73,7 @@ public class KeyValueScriptHistogramFacetCollector extends AbstractFacetCollecto
setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
}
this.valueScript = new SearchScript(context.lookup(), scriptLang, valueScript, params, context.scriptService());
this.valueScript = new ExecutableSearchScript(context.lookup(), scriptLang, valueScript, params, context.scriptService());
FieldMapper mapper = smartMappers.mapper();
@ -104,7 +104,7 @@ public class KeyValueScriptHistogramFacetCollector extends AbstractFacetCollecto
private final long interval;
private final SearchScript valueScript;
private final ExecutableSearchScript valueScript;
private final TLongLongHashMap counts = new TLongLongHashMap();
@ -112,7 +112,7 @@ public class KeyValueScriptHistogramFacetCollector extends AbstractFacetCollecto
private int missing;
public HistogramProc(long interval, SearchScript valueScript) {
public HistogramProc(long interval, ExecutableSearchScript valueScript) {
this.interval = interval;
this.valueScript = valueScript;
}

View File

@ -22,7 +22,7 @@ package org.elasticsearch.search.facet.histogram;
import org.apache.lucene.index.IndexReader;
import org.elasticsearch.common.trove.map.hash.TLongDoubleHashMap;
import org.elasticsearch.common.trove.map.hash.TLongLongHashMap;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.internal.SearchContext;
@ -35,9 +35,9 @@ import java.util.Map;
*/
public class ScriptHistogramFacetCollector extends AbstractFacetCollector {
private final SearchScript keyScript;
private final ExecutableSearchScript keyScript;
private final SearchScript valueScript;
private final ExecutableSearchScript valueScript;
private final long interval;
@ -49,8 +49,8 @@ public class ScriptHistogramFacetCollector extends AbstractFacetCollector {
public ScriptHistogramFacetCollector(String facetName, String scriptLang, String keyScript, String valueScript, Map<String, Object> params, long interval, HistogramFacet.ComparatorType comparatorType, SearchContext context) {
super(facetName);
this.keyScript = new SearchScript(context.lookup(), scriptLang, keyScript, params, context.scriptService());
this.valueScript = new SearchScript(context.lookup(), scriptLang, valueScript, params, context.scriptService());
this.keyScript = new ExecutableSearchScript(context.lookup(), scriptLang, keyScript, params, context.scriptService());
this.valueScript = new ExecutableSearchScript(context.lookup(), scriptLang, valueScript, params, context.scriptService());
this.interval = interval > 0 ? interval : 0;
this.comparatorType = comparatorType;
}

View File

@ -20,7 +20,7 @@
package org.elasticsearch.search.facet.range;
import org.apache.lucene.index.IndexReader;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.internal.SearchContext;
@ -33,16 +33,16 @@ import java.util.Map;
*/
public class ScriptRangeFacetCollector extends AbstractFacetCollector {
private final SearchScript keyScript;
private final ExecutableSearchScript keyScript;
private final SearchScript valueScript;
private final ExecutableSearchScript valueScript;
private final RangeFacet.Entry[] entries;
public ScriptRangeFacetCollector(String facetName, String scriptLang, String keyScript, String valueScript, Map<String, Object> params, RangeFacet.Entry[] entries, SearchContext context) {
super(facetName);
this.keyScript = new SearchScript(context.lookup(), scriptLang, keyScript, params, context.scriptService());
this.valueScript = new SearchScript(context.lookup(), scriptLang, valueScript, params, context.scriptService());
this.keyScript = new ExecutableSearchScript(context.lookup(), scriptLang, keyScript, params, context.scriptService());
this.valueScript = new ExecutableSearchScript(context.lookup(), scriptLang, valueScript, params, context.scriptService());
this.entries = entries;
}

View File

@ -20,7 +20,7 @@
package org.elasticsearch.search.facet.statistical;
import org.apache.lucene.index.IndexReader;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.internal.SearchContext;
@ -33,7 +33,7 @@ import java.util.Map;
*/
public class ScriptStatisticalFacetCollector extends AbstractFacetCollector {
private final SearchScript script;
private final ExecutableSearchScript script;
private double min = Double.NaN;
@ -47,7 +47,7 @@ public class ScriptStatisticalFacetCollector extends AbstractFacetCollector {
public ScriptStatisticalFacetCollector(String facetName, String scriptLang, String script, Map<String, Object> params, SearchContext context) {
super(facetName);
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
}
@Override protected void doCollect(int doc) throws IOException {

View File

@ -31,7 +31,7 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.bytes.ByteFieldData;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -70,7 +70,7 @@ public class TermsByteFacetCollector extends AbstractFacetCollector {
private final StaticAggregatorValueProc aggregator;
private final SearchScript script;
private final ExecutableSearchScript script;
public TermsByteFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context,
String scriptLang, String script, Map<String, Object> params) {
@ -98,7 +98,7 @@ public class TermsByteFacetCollector extends AbstractFacetCollector {
}
if (script != null) {
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
} else {
this.script = null;
}
@ -169,11 +169,11 @@ public class TermsByteFacetCollector extends AbstractFacetCollector {
public static class AggregatorValueProc extends StaticAggregatorValueProc {
private final SearchScript script;
private final ExecutableSearchScript script;
private final Map<String, Object> scriptParams;
public AggregatorValueProc(TByteIntHashMap facets, SearchScript script) {
public AggregatorValueProc(TByteIntHashMap facets, ExecutableSearchScript script) {
super(facets);
this.script = script;
if (script != null) {

View File

@ -31,7 +31,7 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.doubles.DoubleFieldData;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -70,7 +70,7 @@ public class TermsDoubleFacetCollector extends AbstractFacetCollector {
private final StaticAggregatorValueProc aggregator;
private final SearchScript script;
private final ExecutableSearchScript script;
public TermsDoubleFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context,
String scriptLang, String script, Map<String, Object> params) {
@ -98,7 +98,7 @@ public class TermsDoubleFacetCollector extends AbstractFacetCollector {
}
if (script != null) {
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
} else {
this.script = null;
}
@ -169,11 +169,11 @@ public class TermsDoubleFacetCollector extends AbstractFacetCollector {
public static class AggregatorValueProc extends StaticAggregatorValueProc {
private final SearchScript script;
private final ExecutableSearchScript script;
private final Map<String, Object> scriptParams;
public AggregatorValueProc(TDoubleIntHashMap facets, SearchScript script) {
public AggregatorValueProc(TDoubleIntHashMap facets, ExecutableSearchScript script) {
super(facets);
this.script = script;
if (script != null) {

View File

@ -31,7 +31,7 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.floats.FloatFieldData;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -70,7 +70,7 @@ public class TermsFloatFacetCollector extends AbstractFacetCollector {
private final StaticAggregatorValueProc aggregator;
private final SearchScript script;
private final ExecutableSearchScript script;
public TermsFloatFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context,
String scriptLang, String script, Map<String, Object> params) {
@ -98,7 +98,7 @@ public class TermsFloatFacetCollector extends AbstractFacetCollector {
}
if (script != null) {
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
} else {
this.script = null;
}
@ -169,11 +169,11 @@ public class TermsFloatFacetCollector extends AbstractFacetCollector {
public static class AggregatorValueProc extends StaticAggregatorValueProc {
private final SearchScript script;
private final ExecutableSearchScript script;
private final Map<String, Object> scriptParams;
public AggregatorValueProc(TFloatIntHashMap facets, SearchScript script) {
public AggregatorValueProc(TFloatIntHashMap facets, ExecutableSearchScript script) {
super(facets);
this.script = script;
if (script != null) {

View File

@ -31,7 +31,7 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.ints.IntFieldData;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -70,7 +70,7 @@ public class TermsIntFacetCollector extends AbstractFacetCollector {
private final StaticAggregatorValueProc aggregator;
private final SearchScript script;
private final ExecutableSearchScript script;
public TermsIntFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context,
String scriptLang, String script, Map<String, Object> params) {
@ -98,7 +98,7 @@ public class TermsIntFacetCollector extends AbstractFacetCollector {
}
if (script != null) {
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
} else {
this.script = null;
}
@ -169,11 +169,11 @@ public class TermsIntFacetCollector extends AbstractFacetCollector {
public static class AggregatorValueProc extends StaticAggregatorValueProc {
private final SearchScript script;
private final ExecutableSearchScript script;
private final Map<String, Object> scriptParams;
public AggregatorValueProc(TIntIntHashMap facets, SearchScript script) {
public AggregatorValueProc(TIntIntHashMap facets, ExecutableSearchScript script) {
super(facets);
this.script = script;
if (script != null) {

View File

@ -31,7 +31,7 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.longs.LongFieldData;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -71,7 +71,7 @@ public class TermsLongFacetCollector extends AbstractFacetCollector {
private final StaticAggregatorValueProc aggregator;
private final SearchScript script;
private final ExecutableSearchScript script;
public TermsLongFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context,
String scriptLang, String script, Map<String, Object> params) {
@ -99,7 +99,7 @@ public class TermsLongFacetCollector extends AbstractFacetCollector {
}
if (script != null) {
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
} else {
this.script = null;
}
@ -170,11 +170,11 @@ public class TermsLongFacetCollector extends AbstractFacetCollector {
public static class AggregatorValueProc extends StaticAggregatorValueProc {
private final SearchScript script;
private final ExecutableSearchScript script;
private final Map<String, Object> scriptParams;
public AggregatorValueProc(TLongIntHashMap facets, SearchScript script) {
public AggregatorValueProc(TLongIntHashMap facets, ExecutableSearchScript script) {
super(facets);
this.script = script;
if (script != null) {

View File

@ -31,7 +31,7 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.field.data.shorts.ShortFieldData;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -70,7 +70,7 @@ public class TermsShortFacetCollector extends AbstractFacetCollector {
private final StaticAggregatorValueProc aggregator;
private final SearchScript script;
private final ExecutableSearchScript script;
public TermsShortFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context,
String scriptLang, String script, Map<String, Object> params) {
@ -98,7 +98,7 @@ public class TermsShortFacetCollector extends AbstractFacetCollector {
}
if (script != null) {
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
} else {
this.script = null;
}
@ -169,11 +169,11 @@ public class TermsShortFacetCollector extends AbstractFacetCollector {
public static class AggregatorValueProc extends StaticAggregatorValueProc {
private final SearchScript script;
private final ExecutableSearchScript script;
private final Map<String, Object> scriptParams;
public AggregatorValueProc(TShortIntHashMap facets, SearchScript script) {
public AggregatorValueProc(TShortIntHashMap facets, ExecutableSearchScript script) {
super(facets);
this.script = script;
if (script != null) {

View File

@ -30,7 +30,7 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldData;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -62,7 +62,7 @@ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector {
private final StaticAggregatorValueProc aggregator;
private final SearchScript script;
private final ExecutableSearchScript script;
public FieldsTermsStringFacetCollector(String facetName, String[] fieldsNames, int size, InternalStringTermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context,
ImmutableSet<String> excluded, Pattern pattern, String scriptLang, String script, Map<String, Object> params) {
@ -89,7 +89,7 @@ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector {
}
if (script != null) {
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
} else {
this.script = null;
}
@ -152,11 +152,11 @@ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector {
private final Matcher matcher;
private final SearchScript script;
private final ExecutableSearchScript script;
private final Map<String, Object> scriptParams;
public AggregatorValueProc(TObjectIntHashMap<String> facets, ImmutableSet<String> excluded, Pattern pattern, SearchScript script) {
public AggregatorValueProc(TObjectIntHashMap<String> facets, ImmutableSet<String> excluded, Pattern pattern, ExecutableSearchScript script) {
super(facets);
this.excluded = excluded;
this.matcher = pattern != null ? pattern.matcher("") : null;

View File

@ -25,7 +25,7 @@ import org.elasticsearch.common.collect.ImmutableList;
import org.elasticsearch.common.collect.ImmutableSet;
import org.elasticsearch.common.trove.iterator.TObjectIntIterator;
import org.elasticsearch.common.trove.map.hash.TObjectIntHashMap;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.internal.SearchContext;
@ -46,7 +46,7 @@ public class ScriptTermsStringFieldFacetCollector extends AbstractFacetCollector
private final int numberOfShards;
private final SearchScript script;
private final ExecutableSearchScript script;
private final Matcher matcher;
@ -62,7 +62,7 @@ public class ScriptTermsStringFieldFacetCollector extends AbstractFacetCollector
this.size = size;
this.comparatorType = comparatorType;
this.numberOfShards = context.numberOfShards();
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.excluded = excluded;
this.matcher = pattern != null ? pattern.matcher("") : null;

View File

@ -31,7 +31,7 @@ import org.elasticsearch.index.cache.field.data.FieldDataCache;
import org.elasticsearch.index.field.data.FieldData;
import org.elasticsearch.index.field.data.FieldDataType;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.facet.AbstractFacetCollector;
import org.elasticsearch.search.facet.Facet;
import org.elasticsearch.search.facet.FacetPhaseExecutionException;
@ -73,7 +73,7 @@ public class TermsStringFacetCollector extends AbstractFacetCollector {
private final StaticAggregatorValueProc aggregator;
private final SearchScript script;
private final ExecutableSearchScript script;
public TermsStringFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context,
ImmutableSet<String> excluded, Pattern pattern, String scriptLang, String script, Map<String, Object> params) {
@ -98,7 +98,7 @@ public class TermsStringFacetCollector extends AbstractFacetCollector {
}
if (script != null) {
this.script = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
this.script = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
} else {
this.script = null;
}
@ -173,11 +173,11 @@ public class TermsStringFacetCollector extends AbstractFacetCollector {
private final Matcher matcher;
private final SearchScript script;
private final ExecutableSearchScript script;
private final Map<String, Object> scriptParams;
public AggregatorValueProc(TObjectIntHashMap<String> facets, ImmutableSet<String> excluded, Pattern pattern, SearchScript script) {
public AggregatorValueProc(TObjectIntHashMap<String> facets, ImmutableSet<String> excluded, Pattern pattern, ExecutableSearchScript script) {
super(facets);
this.excluded = excluded;
this.matcher = pattern != null ? pattern.matcher("") : null;

View File

@ -21,7 +21,7 @@ package org.elasticsearch.search.fetch;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.SearchParseElement;
import org.elasticsearch.search.fetch.script.ScriptFieldsContext;
import org.elasticsearch.search.internal.SearchContext;
@ -39,7 +39,7 @@ public class FieldsParseElement implements SearchParseElement {
String name = parser.text();
if (name.contains("_source.") || name.contains("doc[")) {
// script field to load from source
SearchScript searchScript = new SearchScript(context.lookup(), null, name, null, context.scriptService());
ExecutableSearchScript searchScript = new ExecutableSearchScript(context.lookup(), null, name, null, context.scriptService());
context.scriptFields().add(new ScriptFieldsContext.ScriptField(name, searchScript, true));
} else {
if ("*".equals(name)) {
@ -52,7 +52,7 @@ public class FieldsParseElement implements SearchParseElement {
added = true;
context.fieldNames().add(name);
} else {
SearchScript searchScript = new SearchScript(context.lookup(), "mvel", "_source." + fieldMapper.names().fullName(), null, context.scriptService());
ExecutableSearchScript searchScript = new ExecutableSearchScript(context.lookup(), "mvel", "_source." + fieldMapper.names().fullName(), null, context.scriptService());
context.scriptFields().add(new ScriptFieldsContext.ScriptField(name, searchScript, true));
}
}
@ -66,7 +66,7 @@ public class FieldsParseElement implements SearchParseElement {
String name = parser.text();
if (name.contains("_source.") || name.contains("doc[")) {
// script field to load from source
SearchScript searchScript = new SearchScript(context.lookup(), null, name, null, context.scriptService());
ExecutableSearchScript searchScript = new ExecutableSearchScript(context.lookup(), null, name, null, context.scriptService());
context.scriptFields().add(new ScriptFieldsContext.ScriptField(name, searchScript, true));
} else {
if ("*".equals(name)) {
@ -77,7 +77,7 @@ public class FieldsParseElement implements SearchParseElement {
if (fieldMapper.stored()) {
context.fieldNames().add(name);
} else {
SearchScript searchScript = new SearchScript(context.lookup(), "mvel", "_source." + fieldMapper.names().fullName(), null, context.scriptService());
ExecutableSearchScript searchScript = new ExecutableSearchScript(context.lookup(), "mvel", "_source." + fieldMapper.names().fullName(), null, context.scriptService());
context.scriptFields().add(new ScriptFieldsContext.ScriptField(name, searchScript, true));
}
} else {

View File

@ -20,7 +20,7 @@
package org.elasticsearch.search.fetch.script;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import java.util.List;
@ -31,10 +31,10 @@ public class ScriptFieldsContext {
public static class ScriptField {
private final String name;
private final SearchScript script;
private final ExecutableSearchScript script;
private final boolean ignoreException;
public ScriptField(String name, SearchScript script, boolean ignoreException) {
public ScriptField(String name, ExecutableSearchScript script, boolean ignoreException) {
this.name = name;
this.script = script;
this.ignoreException = ignoreException;
@ -44,7 +44,7 @@ public class ScriptFieldsContext {
return name;
}
public SearchScript script() {
public ExecutableSearchScript script() {
return this.script;
}

View File

@ -20,7 +20,7 @@
package org.elasticsearch.search.fetch.script;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.SearchParseElement;
import org.elasticsearch.search.internal.SearchContext;
@ -69,7 +69,7 @@ public class ScriptFieldsParseElement implements SearchParseElement {
}
}
}
SearchScript searchScript = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
ExecutableSearchScript searchScript = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
context.scriptFields().add(new ScriptFieldsContext.ScriptField(fieldName, searchScript, ignoreException));
}
}

View File

@ -24,7 +24,7 @@ import org.apache.lucene.search.SortField;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.field.function.sort.DoubleFieldsFunctionDataComparator;
import org.elasticsearch.index.field.function.sort.StringFieldsFunctionDataComparator;
import org.elasticsearch.script.search.SearchScript;
import org.elasticsearch.script.ExecutableSearchScript;
import org.elasticsearch.search.SearchParseException;
import org.elasticsearch.search.internal.SearchContext;
@ -74,7 +74,7 @@ public class ScriptSortParser implements SortParser {
if (type == null) {
throw new SearchParseException(context, "_script sorting requires setting the type of the script");
}
SearchScript searchScript = new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
ExecutableSearchScript searchScript = new ExecutableSearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
FieldComparatorSource fieldComparatorSource;
if ("string".equals(type)) {
fieldComparatorSource = StringFieldsFunctionDataComparator.comparatorSource(searchScript);