本文整理汇总了Java中org.elasticsearch.index.fielddata.ScriptDocValues类的典型用法代码示例。如果您正苦于以下问题:Java ScriptDocValues类的具体用法?Java ScriptDocValues怎么用?Java ScriptDocValues使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScriptDocValues类属于org.elasticsearch.index.fielddata包,在下文中一共展示了ScriptDocValues类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: get
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public ScriptDocValues<?> get(Object key) {
// assume its a string...
String fieldName = key.toString();
ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName);
if (scriptValues == null) {
final MappedFieldType fieldType = mapperService.fullName(fieldName);
if (fieldType == null) {
throw new IllegalArgumentException("No field found for [" + fieldName + "] in mapping with types " + Arrays.toString(types) + "");
}
// load fielddata on behalf of the script: otherwise it would need additional permissions
// to deal with pagedbytes/ramusagestimator/etc
scriptValues = AccessController.doPrivileged(new PrivilegedAction<ScriptDocValues<?>>() {
@Override
public ScriptDocValues<?> run() {
return fieldDataService.getForField(fieldType).load(reader).getScriptValues();
}
});
localCacheFieldData.put(fieldName, scriptValues);
}
scriptValues.setNextDocId(docId);
return scriptValues;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:LeafDocLookup.java
示例2: get
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public Object get(Object key) {
// assume its a string...
String fieldName = key.toString();
ScriptDocValues scriptValues = localCacheFieldData.get(fieldName);
if (scriptValues == null) {
final MappedFieldType fieldType = mapperService.smartNameFieldType(fieldName, types);
if (fieldType == null) {
throw new IllegalArgumentException("No field found for [" + fieldName + "] in mapping with types " + Arrays.toString(types) + "");
}
// load fielddata on behalf of the script: otherwise it would need additional permissions
// to deal with pagedbytes/ramusagestimator/etc
scriptValues = AccessController.doPrivileged(new PrivilegedAction<ScriptDocValues>() {
@Override
public ScriptDocValues run() {
return fieldDataService.getForField(fieldType).load(reader).getScriptValues();
}
});
localCacheFieldData.put(fieldName, scriptValues);
}
scriptValues.setNextDocId(docId);
return scriptValues;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:LeafDocLookup.java
示例3: runAsDouble
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override public double runAsDouble(){
try{
String current_value = ((ScriptDocValues.Strings)doc().get(comparison_field)).getValues().get(0);
String[] strQueryArray = new String[0];
strQueryArray = query.split(" ");
ArrayList intQueryArrayList = new ArrayList();
for(int i = 0; i < strQueryArray.length; i++) {
intQueryArrayList.add(Double.valueOf(strQueryArray[i]));
}
String[] strComparisonArray = new String[0];
strComparisonArray = current_value.split(" ");
ArrayList intComparisonArrayList = new ArrayList();
for(int i = 0; i < strComparisonArray.length; i++) {
intComparisonArrayList.add(Double.valueOf(strComparisonArray[i]));
}
return (double) euclidianDistance(scaleArrayList(intComparisonArrayList,scalepoints), scaleArrayList(intQueryArrayList,scalepoints));
}catch (NullPointerException e){
return 9999999;
}
}
开发者ID:etsy,项目名称:oculus,代码行数:24,代码来源:EuclidianScript.java
示例4: run
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Object run() {
// First we get field using doc lookup
ScriptDocValues<Long> docValue = (ScriptDocValues<Long>) doc().get(fieldName);
// Check if field exists
if (docValue != null && !docValue.isEmpty()) {
try {
// Try to parse it as an integer
BigInteger bigInteger = BigInteger.valueOf(((Longs) docValue).getValue());
// Check if it's prime
return bigInteger.isProbablePrime(certainty);
} catch (NumberFormatException ex) {
return false;
}
}
return false;
}
开发者ID:imotov,项目名称:elasticsearch-native-script-example,代码行数:19,代码来源:IsPrimeSearchScriptFactory.java
示例5: containsKey
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public boolean containsKey(Object key) {
// assume its a string...
String fieldName = key.toString();
ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName);
if (scriptValues == null) {
MappedFieldType fieldType = mapperService.fullName(fieldName);
if (fieldType == null) {
return false;
}
}
return true;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:LeafDocLookup.java
示例6: InternalGlobalOrdinalsIndexFieldData
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
InternalGlobalOrdinalsIndexFieldData(IndexSettings indexSettings, String fieldName, AtomicOrdinalsFieldData[] segmentAfd,
OrdinalMap ordinalMap, long memorySizeInBytes, Function<RandomAccessOrds, ScriptDocValues<?>> scriptFunction) {
super(indexSettings, fieldName, memorySizeInBytes);
this.atomicReaders = new Atomic[segmentAfd.length];
for (int i = 0; i < segmentAfd.length; i++) {
atomicReaders[i] = new Atomic(segmentAfd[i], ordinalMap, i);
}
this.scriptFunction = scriptFunction;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:InternalGlobalOrdinalsIndexFieldData.java
示例7: getScriptValues
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public final ScriptDocValues<?> getScriptValues() {
switch (numericType) {
case DATE:
return new ScriptDocValues.Dates(getLongValues());
case BOOLEAN:
return new ScriptDocValues.Booleans(getLongValues());
default:
return new ScriptDocValues.Longs(getLongValues());
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:AtomicLongFieldData.java
示例8: SortedSetDVOrdinalsIndexFieldData
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
public SortedSetDVOrdinalsIndexFieldData(IndexSettings indexSettings, IndexFieldDataCache cache, String fieldName,
CircuitBreakerService breakerService, Function<RandomAccessOrds, ScriptDocValues<?>> scriptFunction) {
super(indexSettings.getIndex(), fieldName);
this.indexSettings = indexSettings;
this.cache = cache;
this.breakerService = breakerService;
this.scriptFunction = scriptFunction;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:SortedSetDVOrdinalsIndexFieldData.java
示例9: scoringScript
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static Double scoringScript(Map<String, Object> vars, Function<ScoreAccessor, Number> scoring) {
Map<?, ?> doc = (Map) vars.get("doc");
Double index = ((Number) ((ScriptDocValues<?>) doc.get("index")).getValues().get(0)).doubleValue();
Double score = scoring.apply((ScoreAccessor) vars.get("_score")).doubleValue();
Integer factor = (Integer) vars.get("factor");
return Math.log(index + (factor * score));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:RandomScoreFunctionIT.java
示例10: getMinValueScript
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
/**
* Return the minimal value from a set of values.
*/
@SuppressWarnings("unchecked")
static <T extends Comparable<T>> T getMinValueScript(Map<String, Object> vars, T initialValue, String fieldName,
Function<Object, T> converter) {
T retval = initialValue;
Map<?, ?> doc = (Map) vars.get("doc");
ScriptDocValues<?> values = (ScriptDocValues<?>) doc.get(fieldName);
for (Object v : values.getValues()) {
T value = converter.apply(v);
retval = (value.compareTo(retval) < 0) ? value : retval;
}
return retval;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:SimpleSortIT.java
示例11: run
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public Object run() {
if (this.field == null || this.inputFeatureVector == null || this.inputFeatureVectorNorm == 0) {
return this.baseConstant;
}
if (!doc().containsKey(this.field) || doc().get(this.field) == null) {
return this.baseConstant;
}
String docFeatureVectorStr = ((ScriptDocValues.Strings) doc().get(this.field)).getValue();
return calculateScore(docFeatureVectorStr);
}
开发者ID:ginobefun,项目名称:elasticsearch-feature-vector-scoring,代码行数:14,代码来源:FeatureVectorScoringSearchScript.java
示例12: containsKey
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public boolean containsKey(Object key) {
// assume its a string...
String fieldName = key.toString();
ScriptDocValues scriptValues = localCacheFieldData.get(fieldName);
if (scriptValues == null) {
MappedFieldType fieldType = mapperService.smartNameFieldType(fieldName, types);
if (fieldType == null) {
return false;
}
}
return true;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:LeafDocLookup.java
示例13: runAsFloat
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public float runAsFloat() {
String fieldValue = ((ScriptDocValues.Strings) doc().get(field)).getValue();
//Serious arse covering:
if(hash == null || fieldValue == null || fieldValue.length() != hash.length()){
return 0.0f;
}
return hammingDistance(fieldValue, hash);
}
开发者ID:scirag,项目名称:elastic-search-hamming-distance-plugin,代码行数:11,代码来源:HammingDistanceScriptFactory.java
示例14: runAsFloat
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public float runAsFloat() {
String fieldValue = ((ScriptDocValues.Strings) doc().get(field)).getValue();
if (hash == null || fieldValue == null || fieldValue.length() != hash.length()) {
return 0.0f;
}
return hammingDistance(fieldValue, hash);
}
开发者ID:CameraForensics,项目名称:elasticsearch-plugins,代码行数:10,代码来源:HammingDistanceScript.java
示例15: runAsFloat
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public float runAsFloat() {
if (queryCorrelogram == null) {
return Integer.MAX_VALUE;
}
float[][] correlogram = parseCorrelogram(((ScriptDocValues.Strings) doc().get("correlogram")).getValue());
if (correlogram == null) {
return Integer.MAX_VALUE;
}
return getDistance(correlogram, queryCorrelogram);
}
开发者ID:CameraForensics,项目名称:elasticsearch-plugins,代码行数:14,代码来源:AutoColourCorrelogramDistanceScript.java
示例16: runAsFloat
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public float runAsFloat() {
String fieldValue = ((ScriptDocValues.Strings) doc().get(field)).getValue();
if (hash == null || fieldValue == null) {
return (float) maxScore;
}
return euclideanDistance(paramHash, convertFromString(fieldValue));
}
开发者ID:CameraForensics,项目名称:elasticsearch-plugins,代码行数:10,代码来源:EuclideanDistanceScript.java
示例17: getStringField
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
private String getStringField(String fieldName) {
final ScriptDocValues docValues = (ScriptDocValues) doc().get(fieldName);
if (docValues == null) {
logger.warn("Document didn't contain '" + fieldName + '\'');
return null;
}
final List<?> values = docValues.getValues();
if (values == null || values.isEmpty()) {
logger.warn("Document contained no values in '" + fieldName + '\'');
return null;
}
return values.get(0).toString();
}
开发者ID:ezbake,项目名称:ezelastic,代码行数:16,代码来源:EzSecurityVisibilityFilter.java
示例18: run
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override
public Object run() {
ScriptDocValues docValues = (ScriptDocValues) doc().get(securityExpressionField);
if (docValues == null) {
logger.warn("Document didn't contain '" + securityExpressionField + "' for security label check!");
return false;
}
List values = docValues.getValues();
if (values == null || values.isEmpty()) {
logger.warn("Document contained no values in '" + securityExpressionField + "'!");
return false;
}
String visibilityExpression = values.get(0).toString();
Boolean result = (Boolean) cache.get(visibilityExpression);
if (result != null) {
return result;
}
try {
result = visibilityEvaluator.evaluate(new ColumnVisibility(visibilityExpression));
cache.put(visibilityExpression, result);
return result;
} catch (VisibilityParseException e) {
logger.error("Document contained unparseable '" + securityExpressionField + "' <" + visibilityExpression + ">!");
return false;
}
}
开发者ID:jstoneham,项目名称:elasticsearch-accumulo-security,代码行数:32,代码来源:AccumuloVisibilityFilter.java
示例19: getFieldValue
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
/**
* . Reads field value & returns it as String
*
* @param field the object to cast
* @return String object String value
*/
private static String getFieldValue(final Object field) {
String result = "";
if (field instanceof ScriptDocValues.Strings) {
if (!((ScriptDocValues.Strings) field).isEmpty()) {
result = ((ScriptDocValues.Strings) field).getValue();
}
}
if (field instanceof ScriptDocValues.Doubles) {
if (!((ScriptDocValues.Doubles) field).isEmpty()) {
result = Double.toString(((ScriptDocValues.Doubles) field).getValue());
}
}
if (field instanceof ScriptDocValues.Longs) {
if (!((ScriptDocValues.Longs) field).isEmpty()) {
result = Long.toString(((ScriptDocValues.Longs) field).getValue());
}
}
if (field instanceof ScriptDocValues.GeoPoints) {
if (!((ScriptDocValues.GeoPoints) field).isEmpty()) {
ScriptDocValues.GeoPoints point = (ScriptDocValues.GeoPoints) field;
result = String.format(Locale.getDefault(), "%s,%s", point.getLat(), point.getLon());
}
}
return result;
}
开发者ID:YannBrrd,项目名称:elasticsearch-entity-resolution,代码行数:35,代码来源:EntityResolutionScript.java
示例20: runAsDouble
import org.elasticsearch.index.fielddata.ScriptDocValues; //导入依赖的package包/类
@Override public double runAsDouble() {
try{
String current_value = ((ScriptDocValues.Strings)doc().get(comparison_field)).getValues().get(0);
String[] strQueryArray = query.split(" ");
ArrayList intQueryArrayList = new ArrayList();
for(int i = 0; i < strQueryArray.length; i++) {
intQueryArrayList.add(Double.valueOf(strQueryArray[i]));
}
String[] strComparisonArray = current_value.split(" ");
ArrayList intComparisonArrayList = new ArrayList();
for(int i = 0; i < strComparisonArray.length; i++) {
intComparisonArrayList.add(Double.valueOf(strComparisonArray[i]));
}
final TimeSeries tsI = new TimeSeries(scaleArrayList(intQueryArrayList,scalepoints), false, false, ',');
final TimeSeries tsJ = new TimeSeries(scaleArrayList(intComparisonArrayList,scalepoints), false, false, ',');
DistanceFunction distFn = DistanceFunctionFactory.getDistFnByName("EuclideanDistance");
final TimeWarpInfo info = com.dtw.FastDTW.getWarpInfoBetween(tsI, tsJ, radius, distFn);
return (double) info.getDistance();
}catch (NullPointerException e){
return 9999999;
}
}
开发者ID:etsy,项目名称:oculus,代码行数:30,代码来源:DTWScript.java
注:本文中的org.elasticsearch.index.fielddata.ScriptDocValues类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论