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


Java ValueSource.newContext方法代码示例

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


在下文中一共展示了ValueSource.newContext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: setContext

import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
@Override
public void setContext( TransformContext context ) {
  try {
    IndexReader reader = qparser.getReq().getSearcher().getIndexReader();
    readerContexts = reader.leaves();
    docValuesArr = new FunctionValues[readerContexts.size()];

    searcher = qparser.getReq().getSearcher();
    fcontext = ValueSource.newContext(searcher);
    this.valueSource.createWeight(fcontext, searcher);
  } catch (IOException e) {
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:ValueSourceAugmenter.java

示例3: prepare

import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void prepare() throws IOException {
  Map context = ValueSource.newContext(searcher);
  groupBy.createWeight(context, searcher);
  actualGroupsToFind = getMax(offset, numGroups, maxDoc);
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:Grouping.java

示例4: ValueSourceCollapse

import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
public ValueSourceCollapse(int maxDoc,
                           String funcStr,
                           int nullPolicy,
                           int[] ords,
                           boolean max,
                           boolean needsScores,
                           IntIntOpenHashMap boostDocs,
                           FunctionQuery funcQuery, IndexSearcher searcher, SortedDocValues values) throws IOException {
  super(maxDoc, null, nullPolicy, max, needsScores, boostDocs, values);
  this.valueSource = funcQuery.getValueSource();
  this.rcontext = ValueSource.newContext(searcher);
  this.ords = ords;
  this.ordVals = new float[ords.length];
  Arrays.fill(ords, -1);

  if(max) {
    comp = new MaxFloatComp();
    Arrays.fill(ordVals, -Float.MAX_VALUE );
  } else {
    this.nullVal = Float.MAX_VALUE;
    comp = new MinFloatComp();
    Arrays.fill(ordVals, Float.MAX_VALUE);
  }

  if(funcStr.indexOf("cscore()") != -1) {
    this.cscore = true;
    this.rcontext.put("CSCORE",this.collapseScore);
  }

  if(this.needsScores) {
    this.scores = new float[ords.length];
    if(nullPolicy == CollapsingPostFilter.NULL_POLICY_EXPAND) {
      nullScores = new FloatArrayList();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:37,代码来源:CollapsingQParserPlugin.java

示例5: 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

示例6: getStringVal

import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
private String getStringVal(SolrQueryRequest sqr, String field, int doc) throws IOException {
  SchemaField sf = sqr.getSchema().getField(field);
  ValueSource vs = sf.getType().getValueSource(sf, null);
  Map context = ValueSource.newContext(sqr.getSearcher());
  vs.createWeight(context, sqr.getSearcher());
  IndexReaderContext topReaderContext = sqr.getSearcher().getTopReaderContext();
  List<AtomicReaderContext> leaves = topReaderContext.leaves();
  int idx = ReaderUtil.subIndex(doc, leaves);
  AtomicReaderContext leaf = leaves.get(idx);
  FunctionValues vals = vs.getValues(context, leaf);
  return vals.strVal(doc-leaf.docBase);
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:TestIndexSearcher.java

示例7: getFilterCollector

import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
@Override
public DelegatingCollector getFilterCollector(IndexSearcher searcher) {
  Map fcontext = ValueSource.newContext(searcher);
  return new FunctionRangeCollector(fcontext);
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:FunctionRangeQuery.java

示例8: ConstantWeight

import org.apache.lucene.queries.function.ValueSource; //导入方法依赖的package包/类
public ConstantWeight(IndexSearcher searcher) throws IOException {
  this.context = ValueSource.newContext(searcher);
  if (filter instanceof SolrFilter)
    ((SolrFilter)filter).createWeight(context, searcher);
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:SolrConstantScoreQuery.java


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