当前位置: 首页>>代码示例>>Java>>正文


Java ValueSource类代码示例

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


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


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