本文整理汇总了Java中org.apache.lucene.queries.function.docvalues.IntDocValues类的典型用法代码示例。如果您正苦于以下问题:Java IntDocValues类的具体用法?Java IntDocValues怎么用?Java IntDocValues使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntDocValues类属于org.apache.lucene.queries.function.docvalues包,在下文中一共展示了IntDocValues类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getValues
import org.apache.lucene.queries.function.docvalues.IntDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader();
final AtomicReader r = SlowCompositeReaderWrapper.wrap(topReader);
final int off = readerContext.docBase;
final SortedDocValues sindex = FieldCache.DEFAULT.getTermsIndex(r, field);
final int end = sindex.getValueCount();
return new IntDocValues(this) {
@Override
public int intVal(int doc) {
return (end - sindex.getOrd(doc+off) - 1);
}
};
}
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:ReverseOrdFieldSource.java
示例2: getValues
import org.apache.lucene.queries.function.docvalues.IntDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader();
final AtomicReader r = topReader instanceof CompositeReader
? new SlowCompositeReaderWrapper((CompositeReader)topReader)
: (AtomicReader) topReader;
final int off = readerContext.docBase;
final SortedDocValues sindex = FieldCache.DEFAULT.getTermsIndex(r, field);
final int end = sindex.getValueCount();
return new IntDocValues(this) {
@Override
public int intVal(int doc) {
return (end - sindex.getOrd(doc+off) - 1);
}
};
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:ReverseOrdFieldSource.java
示例3: getValues
import org.apache.lucene.queries.function.docvalues.IntDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException
{
final BinaryDocValues terms = cache.getTerms(readerContext.reader(), field, false, PackedInts.FAST);
final IndexReader top = ReaderUtil.getTopLevelContext(readerContext).reader();
Terms t = MultiFields.getTerms(top, qfield);
final TermsEnum termsEnum = t == null ? TermsEnum.EMPTY : t.iterator(null);
return new IntDocValues(this) {
@Override
public int intVal(int doc)
{
try {
final BytesRef term = terms.get(doc);
if (termsEnum.seekExact(term)) {
return termsEnum.docFreq();
} else {
return 0;
}
}
catch (IOException e) {
throw new RuntimeException("caught exception in function "+description()+" : doc="+doc, e);
}
}
};
}
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:JoinDocFreqValueSource.java
示例4: getValues
import org.apache.lucene.queries.function.docvalues.IntDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, final AtomicReaderContext readerContext) throws IOException {
return new IntDocValues(this) {
private final int seed = getSeed(field, readerContext);
@Override
public int intVal(int doc) {
return hash(doc+seed);
}
};
}
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:RandomSortField.java
示例5: getValues
import org.apache.lucene.queries.function.docvalues.IntDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException{
final IndexReader ir = readerContext.reader();
final String indexedField = this.indexedField;
return new IntDocValues(this) {
@Override
public int intVal(int docNum) {
try{
// SH: Fastest method to do this is if the field has term vectors stored
// else we have to re-analyze the field, which is not efficient
// http://stackoverflow.com/questions/3574106/how-to-count-the-number-of-terms-for-each-document-in-lucene-index
final Fields vectors = ir.getTermVectors(docNum);
if(vectors != null){
if (vectors != null) {
Terms vector = vectors.terms(indexedField);
if(vector != null) {
return (int) vector.size();
}
}
}
} catch(java.io.IOException ex){
throw new RuntimeException("caught exception in function " + description()+" while reading term vectors for doc : doc=" + docNum, ex);
}
return getFieldLengthFromAnalysisChain(docNum, indexedField, ir);
}
};
}
开发者ID:DiceTechJobs,项目名称:SolrPlugins,代码行数:31,代码来源:FieldLenValueSource.java
示例6: getValues
import org.apache.lucene.queries.function.docvalues.IntDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException
{
final BinaryDocValues terms = cache.getTerms(readerContext.reader(), field, PackedInts.FAST);
final IndexReader top = ReaderUtil.getTopLevelContext(readerContext).reader();
Terms t = MultiFields.getTerms(top, qfield);
final TermsEnum termsEnum = t == null ? TermsEnum.EMPTY : t.iterator(null);
return new IntDocValues(this) {
final BytesRef ref = new BytesRef();
@Override
public int intVal(int doc)
{
try {
terms.get(doc, ref);
if (termsEnum.seekExact(ref, true)) {
return termsEnum.docFreq();
} else {
return 0;
}
}
catch (IOException e) {
throw new RuntimeException("caught exception in function "+description()+" : doc="+doc, e);
}
}
};
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:29,代码来源:JoinDocFreqValueSource.java
示例7: getValues
import org.apache.lucene.queries.function.docvalues.IntDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException
{
final BinaryDocValues terms = cache.getTerms(readerContext.reader(), field, false, PackedInts.FAST);
final IndexReader top = ReaderUtil.getTopLevelContext(readerContext).reader();
Terms t = MultiFields.getTerms(top, qfield);
final TermsEnum termsEnum = t == null ? TermsEnum.EMPTY : t.iterator(null);
return new IntDocValues(this) {
final BytesRef ref = new BytesRef();
@Override
public int intVal(int doc)
{
try {
terms.get(doc, ref);
if (termsEnum.seekExact(ref)) {
return termsEnum.docFreq();
} else {
return 0;
}
}
catch (IOException e) {
throw new RuntimeException("caught exception in function "+description()+" : doc="+doc, e);
}
}
};
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:29,代码来源:JoinDocFreqValueSource.java
示例8: getValues
import org.apache.lucene.queries.function.docvalues.IntDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(
@SuppressWarnings("rawtypes") final Map context,
final AtomicReaderContext readerContext) throws IOException {
return new IntDocValues(this) {
@Override
public int intVal(final int docId) {
final IndexSearcher searcher = (IndexSearcher) context
.get("searcher");
final Set<String> fieldSet = new HashSet<String>();
fieldSet.add(field);
try {
final Document doc = searcher.doc(docId, fieldSet);
if (doc != null) {
String value = doc.get(field);
if (normalized) {
value = normalize(value);
}
return StringUtils.countMatches(value, word);
}
} catch (final IOException e) {
// ignore
}
return 0;
}
};
}
开发者ID:codelibs,项目名称:fess-solr-plugin,代码行数:28,代码来源:WordFreqValueSourceParser.java
示例9: getValues
import org.apache.lucene.queries.function.docvalues.IntDocValues; //导入依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
Fields fields = readerContext.reader().fields();
final Terms terms = fields.terms(indexedField);
return new IntDocValues(this) {
DocsEnum docs ;
int atDoc;
int lastDocRequested = -1;
{ reset(); }
public void reset() throws IOException {
// no one should call us for deleted docs?
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(indexedBytes, false)) {
docs = termsEnum.docs(null, null);
} else {
docs = null;
}
} else {
docs = null;
}
if (docs == null) {
docs = new DocsEnum() {
@Override
public int freq() {
return 0;
}
@Override
public int docID() {
return DocIdSetIterator.NO_MORE_DOCS;
}
@Override
public int nextDoc() {
return DocIdSetIterator.NO_MORE_DOCS;
}
@Override
public int advance(int target) {
return DocIdSetIterator.NO_MORE_DOCS;
}
};
}
atDoc = -1;
}
@Override
public int intVal(int doc) {
try {
if (doc < lastDocRequested) {
// out-of-order access.... reset
reset();
}
lastDocRequested = doc;
if (atDoc < doc) {
atDoc = docs.advance(doc);
}
if (atDoc > doc) {
// term doesn't match this document... either because we hit the
// end, or because the next doc is after this doc.
return 0;
}
// a match!
return docs.freq();
} catch (IOException e) {
throw new RuntimeException("caught exception in function "+description()+" : doc="+doc, e);
}
}
};
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:80,代码来源:TermFreqValueSource.java
注:本文中的org.apache.lucene.queries.function.docvalues.IntDocValues类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论