本文整理汇总了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();
}
示例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()]));
}
示例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())));
}
示例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);
}
示例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])));
}
示例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])));
}
示例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 });
}