• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ValueSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.lucene.queries.function.ValueSource的典型用法代码示例。如果您正苦于以下问题:Java ValueSource类的具体用法?Java ValueSource怎么用?Java ValueSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ValueSource类属于org.apache.lucene.queries.function包,在下文中一共展示了ValueSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getMethod

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
static ValueSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
    switch (method) {
        case GETVALUE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case ISEMPTY_METHOD:
            return new EmptyMemberValueSource(fieldData);
        case SIZE_METHOD:
            return new CountMethodValueSource(fieldData);
        case MINIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case MAXIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MAX);
        case AVERAGE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.AVG);
        case MEDIAN_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
        case SUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.SUM);
        case COUNT_METHOD:
            return new CountMethodValueSource(fieldData);
        case GET_YEAR_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.YEAR);
        case GET_MONTH_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MONTH);
        case GET_DAY_OF_MONTH_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.DAY_OF_MONTH);
        case GET_HOUR_OF_DAY_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.HOUR_OF_DAY);
        case GET_MINUTES_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MINUTE);
        case GET_SECONDS_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.SECOND);
        default:
            throw new IllegalArgumentException("Member method [" + method + "] does not exist for date field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:DateField.java


示例2: getMethod

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
static ValueSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
    switch (method) {
        case GETVALUE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case ISEMPTY_METHOD:
            return new EmptyMemberValueSource(fieldData);
        case SIZE_METHOD:
            return new CountMethodValueSource(fieldData);
        case MINIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case MAXIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MAX);
        case AVERAGE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.AVG);
        case MEDIAN_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
        case SUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.SUM);
        case COUNT_METHOD:
            return new CountMethodValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member method [" + method + "] does not exist for numeric field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:NumericField.java


示例3: searchIntersect

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
public Object searchIntersect(OCompositeKey key, double distance, OCommandContext context) throws IOException {

    double lat = ((Double) OType.convert(((OCompositeKey) key).getKeys().get(0), Double.class)).doubleValue();
    double lng = ((Double) OType.convert(((OCompositeKey) key).getKeys().get(1), Double.class)).doubleValue();
    SpatialOperation operation = SpatialOperation.Intersects;

    Point p = ctx.makePoint(lng, lat);
    SpatialArgs args = new SpatialArgs(operation, ctx.makeCircle(lng, lat,
        DistanceUtils.dist2Degrees(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM)));
    Filter filter = strategy.makeFilter(args);
    IndexSearcher searcher = searcher();
    ValueSource valueSource = strategy.makeDistanceValueSource(p);
    Sort distSort = new Sort(valueSource.getSortField(false)).rewrite(searcher);

    return new LuceneResultSet(this,
        new SpatialQueryContext(context, searcher, new MatchAllDocsQuery(), filter, distSort).setSpatialArgs(args));
  }
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:18,代码来源:OLuceneLegacySpatialIndexEngine.java


示例4: makeQueryFromShape

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
protected Query makeQueryFromShape(Shape shape) {
  SpatialArgs args = new SpatialArgs(operation, shape);
  if (!Double.isNaN(distErrPct))
    args.setDistErrPct(distErrPct);

  if (score) {
    ValueSource valueSource = strategy.makeDistanceValueSource(shape.getCenter());
    return new CustomScoreQuery(strategy.makeQuery(args), new FunctionQuery(valueSource));
  } else {
    //strategy.makeQuery() could potentially score (isn't well defined) so instead we call
    // makeFilter() and wrap

    Filter filter = strategy.makeFilter(args);
    if (filter instanceof QueryWrapperFilter) {
      return ((QueryWrapperFilter)filter).getQuery();
    } else {
      return new ConstantScoreQuery(filter);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:SpatialFileQueryMaker.java


示例5: getVersionFromIndex

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
public Long getVersionFromIndex(BytesRef idBytes) {
  // TODO: we could cache much of this and invalidate during a commit.
  // TODO: most DocValues classes are threadsafe - expose which.

  RefCounted<SolrIndexSearcher> newestSearcher = ulog.uhandler.core.getRealtimeSearcher();
  try {
    SolrIndexSearcher searcher = newestSearcher.get();
    long lookup = searcher.lookupId(idBytes);
    if (lookup < 0) return null;

    ValueSource vs = versionField.getType().getValueSource(versionField, null);
    Map context = ValueSource.newContext(searcher);
    vs.createWeight(context, searcher);
    FunctionValues fv = vs.getValues(context, searcher.getTopReaderContext().leaves().get((int)(lookup>>32)));
    long ver = fv.longVal((int)lookup);
    return ver;

  } catch (IOException e) {
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error reading version from index", e);
  } finally {
    if (newestSearcher != null) {
      newestSearcher.decref();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:VersionInfo.java


示例6: description

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
@Override
public String description() {
  StringBuilder sb = new StringBuilder();
  sb.append(name()).append('(');
  boolean firstTime = true;
  for (ValueSource source : sources) {
    if (firstTime) {
      firstTime = false;
    } else {
      sb.append(',');
    }
    sb.append(source);
  }
  sb.append(")");
  return sb.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:VectorValueSource.java


示例7: inform

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
@Override
public void inform(SolrCore core) {

  if (core.getUpdateHandler().getUpdateLog() == null) {
    throw new SolrException(SERVER_ERROR,
        "updateLog must be enabled.");
  }

  if (core.getLatestSchema().getUniqueKeyField() == null) {
    throw new SolrException(SERVER_ERROR,
        "schema must have uniqueKey defined.");
  }

  SchemaField userVersionField = core.getLatestSchema().getField(versionField);
  if (userVersionField == null || !userVersionField.stored() || userVersionField.multiValued()) {
    throw new SolrException(SERVER_ERROR,
        "field " + versionField + " must be defined in schema, be stored, and be single valued.");
  }

  try {
    ValueSource vs = userVersionField.getType().getValueSource(userVersionField, null);
    useFieldCache = true;
  } catch (Exception e) {
    log.warn("Can't use fieldcache/valuesource: " + e.getMessage());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:DocBasedVersionConstraintsProcessorFactory.java


示例8: getValueSource

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
@Override
public ValueSource getValueSource(SchemaField field, QParser qparser) {
  field.checkFieldCacheSource(qparser);
  switch (type) {
    case INTEGER:
      return new IntFieldSource( field.getName(), FieldCache.NUMERIC_UTILS_INT_PARSER );
    case FLOAT:
      return new FloatFieldSource( field.getName(), FieldCache.NUMERIC_UTILS_FLOAT_PARSER );
    case DATE:
      return new TrieDateFieldSource( field.getName(), FieldCache.NUMERIC_UTILS_LONG_PARSER );        
    case LONG:
      return new LongFieldSource( field.getName(), FieldCache.NUMERIC_UTILS_LONG_PARSER );
    case DOUBLE:
      return new DoubleFieldSource( field.getName(), FieldCache.NUMERIC_UTILS_DOUBLE_PARSER );
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + field.name);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TrieField.java


示例9: checkValueSource

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
/** scores[] are in docId order */
  protected void checkValueSource(ValueSource vs, float scores[], float delta) throws IOException {
    FunctionQuery q = new FunctionQuery(vs);

//    //TODO is there any point to this check?
//    int expectedDocs[] = new int[scores.length];//fill with ascending 0....length-1
//    for (int i = 0; i < expectedDocs.length; i++) {
//      expectedDocs[i] = i;
//    }
//    CheckHits.checkHits(random(), q, "", indexSearcher, expectedDocs);

    //TopDocs is sorted but we actually don't care about the order
    TopDocs docs = indexSearcher.search(q, 1000);//calculates the score
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      ScoreDoc gotSD = docs.scoreDocs[i];
      float expectedScore = scores[gotSD.doc];
      assertEquals("Not equal for doc "+gotSD.doc, expectedScore, gotSD.score, delta);
    }

    CheckHits.checkExplanations(q, "", indexSearcher);
  }
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:StrategyTestCase.java


示例10: getValueSource

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
@Override
public ValueSource getValueSource(String name) {
  Object o = map.get(name);
  if (o == null) {
    throw new IllegalArgumentException("Invalid reference '" + name + "'");
  } else if (o instanceof Expression) {
    return ((Expression)o).getValueSource(this);
  } else if (o instanceof ValueSource) {
    return ((ValueSource)o);
  }
  SortField field = (SortField) o;
  switch(field.getType()) {
    case INT:
      return new IntFieldSource(field.getField(), (IntParser) field.getParser());
    case LONG:
      return new LongFieldSource(field.getField(), (LongParser) field.getParser());
    case FLOAT:
      return new FloatFieldSource(field.getField(), (FloatParser) field.getParser());
    case DOUBLE:
      return new DoubleFieldSource(field.getField(), (DoubleParser) field.getParser());
    case SCORE:
      return getScoreValueSource();
    default:
      throw new UnsupportedOperationException(); 
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:SimpleBindings.java


示例11: ExpressionValueSource

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
ExpressionValueSource(Bindings bindings, Expression expression) {
  if (bindings == null) throw new NullPointerException();
  if (expression == null) throw new NullPointerException();
  this.expression = expression;
  variables = new ValueSource[expression.variables.length];
  boolean needsScores = false;
  for (int i = 0; i < variables.length; i++) {
    ValueSource source = bindings.getValueSource(expression.variables[i]);
    if (source instanceof ScoreValueSource) {
      needsScores = true;
    } else if (source instanceof ExpressionValueSource) {
      if (((ExpressionValueSource)source).needsScores()) {
        needsScores = true;
      }
    } else if (source == null) {
      throw new RuntimeException("Internal error. Variable (" + expression.variables[i] + ") does not exist.");
    }
    variables[i] = source;
  }
  this.needsScores = needsScores;
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:ExpressionValueSource.java


示例12: getVariable

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
static ValueSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
    switch (variable) {
        case VALUE_VARIABLE:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case EMPTY_VARIABLE:
            return new EmptyMemberValueSource(fieldData);
        case LENGTH_VARIABLE:
            return new CountMethodValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for date field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:DateField.java


示例13: getVariable

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
static ValueSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
    switch (variable) {
        case VALUE_VARIABLE:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case EMPTY_VARIABLE:
            return new EmptyMemberValueSource(fieldData);
        case LENGTH_VARIABLE:
            return new CountMethodValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for " + 
                                               "numeric field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:NumericField.java


示例14: getVariable

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
static ValueSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
    switch (variable) {
        case EMPTY_VARIABLE:
            return new GeoEmptyValueSource(fieldData);
        case LAT_VARIABLE:
            return new GeoLatitudeValueSource(fieldData);
        case LON_VARIABLE:
            return new GeoLongitudeValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for geo field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:GeoField.java


示例15: getMethod

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
static ValueSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
    switch (method) {
        case ISEMPTY_METHOD:
            return new GeoEmptyValueSource(fieldData);
        case GETLAT_METHOD:
            return new GeoLatitudeValueSource(fieldData);
        case GETLON_METHOD:
            return new GeoLongitudeValueSource(fieldData);
        default:
            throw new IllegalArgumentException("Member method [" + method + "] does not exist for geo field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:GeoField.java


示例16: parse

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
    String field=fp.parseArg();                          // eg. cl_hi
    String featureString = fp.parseArg();
    // System.out.println(featureString);
    byte[] hist= Base64.decodeBase64(featureString);     // eg. FQY5DhMYDg0ODg0PEBEPDg4ODg8QEgsgEBAQEBAgEBAQEBA=
    double maxDistance = Double.MAX_VALUE;
    if (fp.hasMoreArguments()) {                           // if there is a third argument, it's the max value to return if there is none. Note the query cache is not updated upon parameter change.
        maxDistance = Double.parseDouble(fp.parseArg());
    }
    return new LireValueSource(field, hist, maxDistance);
}
 
开发者ID:dermotte,项目名称:liresolr,代码行数:13,代码来源:LireValueSourceParser.java


示例17: parseSfield

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
private MultiValueSource parseSfield(FunctionQParser fp) throws SyntaxError {
    String sfield = fp.getParam(SpatialParams.FIELD);
    if (sfield == null) return null;
    SchemaField sf = fp.getReq().getSchema().getField(sfield);
    FieldType type = sf.getType();
    if (type instanceof AbstractSpatialFieldType) {
        AbstractSpatialFieldType asft = (AbstractSpatialFieldType) type;
        return new SpatialStrategyMultiValueSource(asft.getStrategy(sfield));
    }
    ValueSource vs = type.getValueSource(sf, fp);
    if (vs instanceof MultiValueSource) {
        return (MultiValueSource)vs;
    }
    throw new SyntaxError("Spatial field must implement MultiValueSource or extend AbstractSpatialFieldType:" + sf);
}
 
开发者ID:gogobot,项目名称:solr-distance-cluster,代码行数:16,代码来源:DistanceParser.java


示例18: getValueSource

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
@Override
public ValueSource getValueSource(SchemaField field, QParser parser) {
  ArrayList<ValueSource> vs = new ArrayList<>(dimension);
  for (int i=0; i<dimension; i++) {
    SchemaField sub = subField(field, i, schema);
    vs.add(sub.getType().getValueSource(sub, parser));
  }
  return new PointTypeValueSource(field, vs);
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:PointType.java


示例19: getDistanceValueSource

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
private ValueSource getDistanceValueSource() {
  Expression distance;
  try {
    distance = JavascriptCompiler.compile(
                "haversin(" + ORIGIN_LATITUDE + "," + ORIGIN_LONGITUDE + ",latitude,longitude)");
  } catch (ParseException pe) {
    // Should not happen
    throw new RuntimeException(pe);
  }
  SimpleBindings bindings = new SimpleBindings();
  bindings.add(new SortField("latitude", SortField.Type.DOUBLE));
  bindings.add(new SortField("longitude", SortField.Type.DOUBLE));

  return distance.getValueSource(bindings);
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:DistanceFacetsExample.java


示例20: SpatialWeight

import org.apache.lucene.queries.function.ValueSource; //导入依赖的package包/类
public SpatialWeight(IndexSearcher searcher) throws IOException {
  this.searcher = searcher;
  this.latContext = ValueSource.newContext(searcher);
  this.lonContext = ValueSource.newContext(searcher);
  latSource.createWeight(latContext, searcher);
  lonSource.createWeight(lonContext, searcher);
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:LatLonType.java



注:本文中的org.apache.lucene.queries.function.ValueSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AccelDeviceEventListener类代码示例发布时间:2022-05-21
下一篇:
Java Literal类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap