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


Java DoubleConstValueSource类代码示例

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


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

示例1: testEmptyReader

import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource; //导入依赖的package包/类
@Test
public void testEmptyReader() throws IOException {
  Directory dir = newDirectory();
  IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
  iwc.setMergePolicy(newLogMergePolicy());
  // Make sure the index is created?
  RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
  writer.commit();
  writer.close();
  IndexReader ir = DirectoryReader.open(dir);
  Dictionary dictionary = new DocumentValueSourceDictionary(ir, FIELD_NAME,  new DoubleConstValueSource(10), PAYLOAD_FIELD_NAME);
  InputIterator inputIterator = dictionary.getEntryIterator();

  assertNull(inputIterator.next());
  assertEquals(inputIterator.weight(), 0);
  assertNull(inputIterator.payload());

  ir.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:DocumentValueSourceDictionaryTest.java

示例2: parse

import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
    // hitcount() takes no arguments.  If we wanted to pass a query
    // we could call fp.parseNestedQuery()
    HashSet<String> fields = new HashSet<String>(); 
    while (fp.hasMoreArguments()) {
        fields.add(fp.parseArg());
    }
    Query q = fp.subQuery(fp.getParams().get("q"), "lucene").getQuery();
    HashSet<Term> terms = new HashSet<Term>(); 
    try {
        q.extractTerms(terms);
    } catch (UnsupportedOperationException e) {
        return new DoubleConstValueSource (1);
    }
    ArrayList<ValueSource> termcounts = new ArrayList<ValueSource>();
    for (Term t : terms) {
        if (fields.isEmpty() || fields.contains (t.field())) {
            termcounts.add (new TermFreqValueSource(t.field(), t.text(), t.field(), t.bytes()));
        }
    }
    return new SumFloatFunction(termcounts.toArray(new ValueSource[termcounts.size()]));
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:24,代码来源:HitCount.java

示例3: parsePoint

import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource; //导入依赖的package包/类
private MultiValueSource parsePoint(FunctionQParser fp) throws SyntaxError {
  String ptStr = fp.getParam(SpatialParams.POINT);
  if (ptStr == null) return null;
  Point point = SpatialUtils.parsePointSolrException(ptStr, SpatialContext.GEO);
  //assume Lat Lon order
  return new VectorValueSource(
      Arrays.<ValueSource>asList(new DoubleConstValueSource(point.getY()), new DoubleConstValueSource(point.getX())));
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:GeoDistValueSourceParser.java

示例4: parse

import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource; //导入依赖的package包/类
@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
    ParamInfo paramInfo = parseTerm(fp);
    if(paramInfo == null){
        return new DoubleConstValueSource(-1.0d);
    }

    if(paramInfo.terms.size() == 0){
        return new DoubleConstValueSource(0.0d);
    }

    return new TermIntersectsValueSource(paramInfo.field, paramInfo.analyzer, paramInfo.terms, paramInfo.similarity);
}
 
开发者ID:DiceTechJobs,项目名称:SolrPlugins,代码行数:14,代码来源:TermIntersectsValueSourceParser.java

示例5: parsePoint

import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource; //导入依赖的package包/类
private MultiValueSource parsePoint(FunctionQParser fp) throws SyntaxError {
    String pt = fp.getParam(SpatialParams.POINT);
    if (pt == null) return null;
    double[] point = null;
    try {
        point = ParseUtils.parseLatitudeLongitude(pt);
    } catch (InvalidShapeException e) {
        throw new SyntaxError("Bad spatial pt:" + pt);
    }
    return new VectorValueSource(Arrays.<ValueSource>asList(new DoubleConstValueSource(point[0]), new DoubleConstValueSource(point[1])));
}
 
开发者ID:gogobot,项目名称:solr-distance-cluster,代码行数:12,代码来源:DistanceParser.java

示例6: parsePoint

import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource; //导入依赖的package包/类
private static MultiValueSource parsePoint(FunctionQParser fp) throws SyntaxError {
  String pt = fp.getParam(SpatialParams.POINT);
  if (pt == null) return null;
  double[] point = null;
  try {
    point = ParseUtils.parseLatitudeLongitude(pt);
  } catch (InvalidShapeException e) {
    throw new SyntaxError("Bad spatial pt:" + pt);
  }
  return new VectorValueSource(Arrays.<ValueSource>asList(new DoubleConstValueSource(point[0]),new DoubleConstValueSource(point[1])));
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:12,代码来源:HaversineConstFunction.java

示例7: testDoubleConst

import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource; //导入依赖的package包/类
public void testDoubleConst() throws Exception {
  assertHits(new FunctionQuery(new DoubleConstValueSource(0.3d)),
      new float[] { 0.3f, 0.3f });
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:TestValueSources.java


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