本文整理汇总了Java中org.apache.lucene.queries.function.docvalues.FloatDocValues类的典型用法代码示例。如果您正苦于以下问题:Java FloatDocValues类的具体用法?Java FloatDocValues怎么用?Java FloatDocValues使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FloatDocValues类属于org.apache.lucene.queries.function.docvalues包,在下文中一共展示了FloatDocValues类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getValues
import org.apache.lucene.queries.function.docvalues.FloatDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
IndexSearcher searcher = (IndexSearcher)context.get("searcher");
final TFIDFSimilarity similarity = IDFValueSource.asTFIDF(searcher.getSimilarity(), field);
if (similarity == null) {
throw new UnsupportedOperationException("requires a TFIDFSimilarity (such as DefaultSimilarity)");
}
final NumericDocValues norms = readerContext.reader().getNormValues(field);
if (norms == null) {
return new ConstDoubleDocValues(0.0, this);
}
return new FloatDocValues(this) {
@Override
public float floatVal(int doc) {
return similarity.decodeNormValue(norms.get(doc));
}
};
}
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:NormValueSource.java
示例2: getValues
import org.apache.lucene.queries.function.docvalues.FloatDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
IndexSearcher searcher = (IndexSearcher)context.get("searcher");
final TFIDFSimilarity similarity = IDFValueSource.asTFIDF(searcher.getSimilarity(), field);
if (similarity == null) {
throw new UnsupportedOperationException("requires a TFIDFSimilarity (such as DefaultSimilarity)");
}
final NumericDocValues norms = readerContext.reader().getNormValues(field);
if (norms == null) {
return new ConstDoubleDocValues(0.0, this);
}
return new FloatDocValues(this) {
@Override
public float floatVal(int doc) {
return similarity.decodeNormValue((byte)norms.get(doc));
}
};
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:21,代码来源:NormValueSource.java
示例3: getValues
import org.apache.lucene.queries.function.docvalues.FloatDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(@SuppressWarnings("rawtypes") Map context, final LeafReaderContext readerContext)
throws IOException {
final FunctionValues sourceValues = source.getValues(context, readerContext);
return new FloatDocValues(this) {
@Override
public float floatVal(int doc) throws IOException {
if (isValidAtomicReaderContext(readerContext)) {
if (!isCached(doc)) {
cache.setFloat(doc, sourceValues.floatVal(doc));
}
return cache.getFloat(doc);
}
return sourceValues.floatVal(doc);
}
};
}
开发者ID:shopping24,项目名称:solr-bmax-queryparser,代码行数:21,代码来源:FloatCachingValueSource.java
示例4: getValues
import org.apache.lucene.queries.function.docvalues.FloatDocValues; //导入依赖的package包/类
public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
final IndexReader ir = readerContext.reader();
final String indexedField = this.indexedField;
return new FloatDocValues(this) {
public float floatVal(int docNum) {
if(valuesToIntersect.size() == 0){
return 0;
}
HashSet<String> fieldValues = null;
try {
final Fields vectors= ir.getTermVectors(docNum);
if (vectors != null) {
if (vectors != null) {
Terms vector = vectors.terms(indexedField);
if (vector != null) {
fieldValues = new HashSet<String>(TermExtractionHelper.getTermsFromTermVectorField(vector));
}
}
}
if(fieldValues == null){
Set<String> fields = new HashSet<String>();
fields.add(indexedField);
Document d = ir.document(docNum, fields);
IndexableField field = d.getField(indexedField);
if (field != null) {
fieldValues = new HashSet<String>(TermExtractionHelper.getTermsFromField(analyzer, field));
}
}
if(fieldValues == null || fieldValues.size() == 0){
return 0;
}
// store field size before modifying set
int fieldSize = fieldValues.size();
if(similarity.equals(SimilarityType.JACCARD)){
HashSet<String> union = new HashSet<String>(fieldValues);
union.addAll(valuesToIntersect);
// intersection
fieldValues.retainAll(valuesToIntersect);
float intersection = fieldValues.size();
// no divide by zero as asserted field size is > 0, thus union > 0
return intersection / union.size();
}
fieldValues.retainAll(valuesToIntersect);
float intersectionSize = fieldValues.size();
if(intersectionSize == 0){
return 0;
}
if(similarity.equals(SimilarityType.DOC_LEN)){
return intersectionSize / fieldSize;
}
if(similarity.equals(SimilarityType.PARAM_LEN)){
return intersectionSize / valuesToIntersect.size();
}
else if(similarity.equals(SimilarityType.DICE)) {
return (2*intersectionSize) / (fieldSize + valuesToIntersect.size());
}
return 0;
}
catch(Exception e){
e.printStackTrace();
}
return 0;
};
};
}
开发者ID:DiceTechJobs,项目名称:SolrPlugins,代码行数:75,代码来源:TermIntersectsValueSource.java
注:本文中的org.apache.lucene.queries.function.docvalues.FloatDocValues类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论